• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

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

KingNothing

Diamond Member
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?
 
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.
 
Back
Top