Hi Jungs,
wie erzeugt ihr eine Gleitpunktzahl aus 32 Bit Input?
Ich hab da ein bisl was angefangen, will in BG_LOG laufen lassen, aber es wird riesig:
Code
1: !Es soll eine Kommazahl erzeugt werden;
1: !Format Big Endian, Siemens;
1: !Das erste Bit DI[201];
1: R[151]=(201);
1: !Bit 0-22 Mantisse;
1: !Bit 23-30 Charakteristik;
1: !Bit 31 Vorzeichen;
1: !*****************************;
1: !Exponent;
1: !Entweder GI, oder so;
1: !Anfang;
1: R[153]=(0);
1: !Exponent Bit0;
1: R[152]=(R[151]+23);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+1);
1: !Exponent Bit1;
1: R[152]=(R[151]+24);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+2);
1: !Exponent Bit2;
1: R[152]=(R[151]+25);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+4);
1: !Exponent Bit3;
1: R[152]=(R[151]+26);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+8);
1: !Exponent Bit4;
1: R[152]=(R[151]+27);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+16);
1: !Exponent Bit5;
1: R[152]=(R[151]+28);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+32);
1: !Exponent Bit6;
1: R[152]=(R[151]+29);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+64);
1: !Exponent Bit7;
1: R[152]=(R[151]+30);
1: IF(DI[R[152]]=ON),R[153]=(R[153]+128);
1: !Bsp. 1000 0011=131;
1: !Umwandeln in Binärstellen;
1: R[153]=(R[153]-127);
1: !Bsp. 131-127=4;
1: !*****************************;
1: !Vorkommazahl;
1: !*****************************;
1: !Mantisse mit 17 Bit-Auflösung;
1: !Anfang;
1: R[154]=(0);
1: !Mantisse Bit0;
1: R[152]=(R[151]+22-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=0),R[154]=(R[154]+1);
1: !Mantisse Bit1;
1: R[152]=(R[151]+21-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=1),R[154]=(R[154]+2);
1: !Mantisse Bit2;
1: R[152]=(R[151]+20-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=2),R[154]=(R[154]+4);
1: !Mantisse Bit3;
1: R[152]=(R[151]+19-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=3),R[154]=(R[154]+8);
1: !Mantisse Bit4;
1: R[152]=(R[151]+18-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=4),R[154]=(R[154]+16);
1: !Mantisse Bit5;
1: R[152]=(R[151]+17-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=5),R[154]=(R[154]+32);
1: !Mantisse Bit6;
1: R[152]=(R[151]+16-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=6),R[154]=(R[154]+64);
1: !Mantisse Bit7;
1: R[152]=(R[151]+15-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=7),R[154]=(R[154]+128);
1: !Mantisse Bit8;
1: R[152]=(R[151]+14-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=8),R[154]=(R[154]+256);
1: !Mantisse Bit9;
1: R[152]=(R[151]+13-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=9),R[154]=(R[154]+512);
1: !Mantisse Bit10;
1: R[152]=(R[151]+12-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=10),R[154]=(R[154]+1024);
1: !Mantisse Bit11;
1: R[152]=(R[151]+11-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=11),R[154]=(R[154]+2048);
1: !Mantisse Bit12;
1: R[152]=(R[151]+10-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=12),R[154]=(R[154]+4096);
1: !Mantisse Bit13;
1: R[152]=(R[151]+9-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=13),R[154]=(R[154]+8192);
1: !Mantisse Bit14;
1: R[152]=(R[151]+8-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=14),R[154]=(R[154]+16384);
1: !Mantisse Bit15;
1: R[152]=(R[151]+7-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=15),R[154]=(R[154]+32768);
1: !Mantisse Bit16;
1: R[152]=(R[151]+6-R[153]);
1: IF(DI[R[152]]=ON AND R[153]>=16),R[154]=(R[154]+65536);
1: !*****************************;
1: !Nachkommazahl;
1: !*****************************;
1: ;
1: ;
1: ;
1: ;
Alles anzeigen
Ist noch nicht fertig und nicht getestet. Auch die Zahl noch nicht inbegriffen.
Hab mir die Seite http://www.h-schmidt.net/FloatConverter/IEEE754de.html zur Hilfe gezogen
Eine Karel-Funktion ist mir auch nicht bekannt
Gruß heinrich