Skip to main content
gamedev.net
🔒 Locked

Floating point format

Started by LilBudyWizer Jun 28, 2004 at 1:39 PM 0 replies 650+ views
Original Post
LilBudyWizer
LilBudyWizer
This came up in a thread that is a bit esoteric so I thought it might be worth repeating in a seperate thread...
Quote:
Original post by Dredge-Master Assuming Little Edian (Edit: I've put Big Edian next to it in comments, just swap the values - on an 0x8086 based processor you should be using little edian so just leave the code as is).

  typedef union
  {
    float f;
    struct float_bits
    {
      unsigned int mantissa : 23; // negative:1
      unsigned int exponent : 8; // exponent:8
      unsigned int negative : 1; // mantissa:23
    }
    ieee_bits;
  }
  ieee754_float;
It provides a nice easy way to inspect how a floating point number is stored and play with them. If you're going to use floating point heavy then you should understand them along the same lines as you understand integer.
Keys to success: Ability, ambition and opportunity.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.