How is a floating point number stored in memory in a C program, specifically on an iBook?

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
I've been doing some google searches but haven't come up with a good explanation yet.

Edit: The Java program I'm writing is supposed to take a binary data file created on an iBook, account for the little endian/big endian difference, and print the data out. The C structure written to the file is:

char name[30]
char e-mail[30]
char flags
float gpa

The first 3 are 30 bytes, 30 bytes, and 1 byte respectively, but the last one?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Assume you have a 32 bit flaoting point number. the first bit is the sign bit, the next 8 bits represent the exponent, and the last 23 bits represent the number. so, take the last 23 bits, and multiply by 10 raised to the exponent component. The exponent component is normalized by subtracting 127, so you have an exponent range of -127 to 128.