handling T.min the right way

Bill Baxter dnewsgroup at billbaxter.com
Tue Mar 20 23:08:40 PDT 2007


James Dennett wrote:
> Walter Bright wrote:
>> 0ffh wrote:
>>> Don Clugston wrote:
>>>> completely different. (For example, I don't know why x++ is legal for
>>>> floating point types; I think it's just a newbie trap; you have no
>>>> guarantee that x++ is different to x).
>>> Nope, not at all.
>>> Standard C defines that after "x++" x is incremented by one, exactly -
>>> *even for fp types* !
>> For floating point types, if x happens to be +-infinity then x+1==x.
> 
> Or, most likely, even if x happens to be 1E100.  I've not
> had the pleasure of working on hardware which supported
> floating point accurate enough to distinguish 1E100 from
> 1+1E100.
> 
> -- James
> 

The cutoff is basically 2^{mantissa bits+1}.
With floats:  2^23 + 1 == 2^23
With double:  2^53 + 1 == 2^53

So it happens for values much less than 1e100.  More like 1e7 and 1e16.

--bb



More information about the Digitalmars-d mailing list