a way to specily floating-point numbers as bit patters

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 9 10:25:22 PDT 2017


Honey wrote:

> On Friday, 9 June 2017 at 16:34:28 UTC, ketmar wrote:
>>> Try -0.16666685f.
>>
>> it doesn't matter if i can find the decimal representation for the given 
>> bit pattern or not. the whole post is about removing the need to rely on 
>> lossy binary->decimal->binary conversions.
>
> Lossless turn-around is guaranteed if you are using sufficiently many 
> digits. In case of IEEE-754 single precision it's 8 significant decimal 
> digits.

it is highly platform-dependent. and both bin->dec, and dec->bin conversion 
routines can contain errors, btw. so using decimal forms for exact 
bit-patterns is the last thing i want to do, as i know how fragile they are.


More information about the Digitalmars-d-learn mailing list