# [Bf-committers] Verse 2005 Errors

Branan Riley branan at gmail.com
Thu Sep 14 22:44:45 CEST 2006

```and I just realized what I've done wrong.  1.11111111111111111111111.
NOT 111111111111111111111111. Subtracting 23 from the exponent to make
up for my stupidity gives... 340282346638528859811704183484516925440
which is 3.402823466385288598e+38

On 9/14/06, Branan Riley <branan at gmail.com> wrote:
> alright... 32-bit float has a 1-bit sign, 8-bit exponent and 23-bit
> significand, right?
>
> OK. the 8-bit exponent gives us a maximum power of 127, since there's
> a bias to allow for negative exponents.
>
> The maximum floating point number is normalized, so it's
> 1.xxxxxxxxxxxxxxxxxxxxxxx, which is a 24-bit number with the first bit
> always set. Since we're going for the maximum number, that value is
> all ones: 1.11111111111111111111111
>
> That value is 16777215.
>
> Floating point numbers = significand * 2^exponent. In this case, that
> should be 1677215 * 2^127. which is showing up as inf because it's
> been rounded up. Try changing that last 2 to a 1, and see what
> happens.
>
> On 9/14/06, Emil Brink <emil at obsession.se> wrote:
> > Branan Riley wrote:
> > > 16,777,215 * 2^127.
> >
> > Hm ... I don't think that is the correct interpretation of the bit pattern
> > as a float.
> >
> > > Running that through Kcalc, I get 2.854495215270736302e+45. I'd do it out
> >  > by hand to get an exact number, but that's a 152-bit number, so I'm not
> >  > going to even think about it. If someone wants to run that through, and
> >  > see what comes up for the binary representation, that would be nifty.
> >
> > Okay ... I think you lost me, though. I'm expecting the float literal
> > to have a decimal exponent of +38, that part has never been in doubt.
> > If the proper value has an exponent of +45, I'd be ... very surprised.
> >
> > A quick test with the above value:
> >
> > ~> gcc -x c -
> > #include <stdio.h>
> > int main(void)
> > {
> >   float a = 2.854495215270736302e+45;
> >   printf("a=%g\n", a);
> >   return 0;
> > }
> > ~> ./a.out
> > a=inf
> >
> > Seems to show that you've lost not only me, but the C compiler as well.
> >
> > Can you run that by me again?
> >
> > Regards,
> >
> > /Emil
> >
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at projects.blender.org
> > http://projects.blender.org/mailman/listinfo/bf-committers
> >
>
```