[LLVMdev] confused about float literals

Joe Armstrong joearms at gmail.com
Thu Apr 28 02:14:34 PDT 2011


On Wed, Apr 27, 2011 at 5:32 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>
> On Apr 27, 2011, at 1:03 AM, Joe Armstrong wrote:
>
> But what is 0x400928F5C0000000? it is NOT the 64 bit representation
> with the low order
> 32 bits zeroed - it is the 62 bit representation with the low order 28
> bits zeroed.
>
> Why 28 bits? - 32 bits might be understandable but not 28.
>
> I bet the low 29 bits are zeroed. That is the difference between the 52 bit
> double significand and the 23 bit float significand.
> This is what you get if 3.145 is first converted to a float and then to a
> double.
> /jakob
>

This seems to be empirically true. So to convert a float32 I zero the low order
29 bits in the 64 bit equivalent representation and render the result in hex.

So right now the documentation and the code are in disagreement :-)

/Joe



More information about the llvm-dev mailing list