how to read the binary value of a floating point ?

Status
Not open for further replies.

mdamdam

Member level 3
Joined
Apr 12, 2002
Messages
55
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
the old Europa
Activity points
464
I am working in Delphi,
I need to convert a 4 byte floating point number ( single ) into the 4 variable of one byte.
example:

var
i : single;
i1,i2,i3,i4 : byte;

begin
i:=15;
...
// in memory i= $41 70 00 00 in IEEE 4 byte format

how can I convert i to i1=$41 , i2 = $70, i3=$00, i4=$00 ????

Many thanks
DamDam
 

In C language :

char i1,i2,i3,i4,*ptr;
float i; // i:single in pascal

ptr=(char * ) &i;
i1=*ptr;
i2=*(ptr+1)
i3=*(ptr+2)
i4=*(ptr+3)
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…