integral to floating point conversion

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 2 14:20:57 PDT 2016


On 7/2/2016 1:49 PM, Andrei Alexandrescu wrote:
> On 7/2/16 4:30 PM, 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.
>
> What is the largest unsigned value represented by the float's mantissa bits? I
> recall there is a constant somewhere for it. -- Andrei

https://en.wikipedia.org/wiki/Single-precision_floating-point_format

24 bits. So it can store +-0x0FFF_FFFF


More information about the Digitalmars-d mailing list