integral to floating point conversion
Matthias Bentrup via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 3 01:53:41 PDT 2016
On Saturday, 2 July 2016 at 20:30:03 UTC, Walter Bright wrote:
> On 7/2/2016 1:17 PM, Andrei Alexandrescu wrote:
>> So what's the fastest way to figure that an integral is
>> convertible to a
>> floating point value precisely (i.e. no other integral
>> converts to the same
>> floating point value)? Thanks! -- Andrei
>
> Test that its absolute value is <= the largest unsigned value
> represented by the float's mantissa bits.
That has to be '<' given the condition that no other integer
converts to
the same value. Although 2^n can be represented exactly, 2^n+1
would be converted to the same float value.
More information about the Digitalmars-d
mailing list