[Bf-committers] Verse 2005 Errors
branan at gmail.com
Fri Sep 15 01:01:10 CEST 2006
# define SET_TO_MAX_FLOAT(x) *((unsigned*)(&x)) = 0x7f7fffff
On 9/14/06, Emil Brink <emil at obsession.se> wrote:
> Branan Riley wrote:
> > 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
> > *slaps forehead*
> Exactly, that period is the "binary period", separating the integer
> part of the number from the fractional part. Thanks for clearing that
> up, that is what I didn't get with your first posting.
> Now, the thing is that even given that exact (?) decimal version of
> the number, I'm still not sure how to figure out in a totally "safe"
> manner where the precision actually ends.
> For sure, a float does not have that many decimal digits of precision,
> my testing says it's enough to use 3.40282347e+38, i.e. nine digits
> I don't dare use all the digits in the literal, since that is exactly
> what triggers the compilation error on some Microsoft compilers; they
> complain about the constant being "too large" (see start of thread).
> Bf-committers mailing list
> Bf-committers at projects.blender.org
More information about the Bf-committers