[LLVMdev] Generating Floating point constants

Dale Johannesen dalej at apple.com
Thu Jun 3 10:41:16 PDT 2010

On Jun 3, 2010, at 7:05 AMPDT, Stéphane Letz wrote:
> Le 3 juin 2010 à 16:00, Martin Guy a écrit :
>> [off list]
>>> 0.8f get converted in 0x3FE99999A0000000 by LLVM
>> single precision
>>> http://babbage.cs.qc.edu/IEEE-754/Decimal.html  gives:
>>> 0x3FE999999999999A  instead and this value cannot be read back by  
>>> "llc"...
>> double precision

Martin is right.  Floats have only 36 significant bits  (sign + 11  
exponent + 24 mantissa) and are stored that way.  (The exponent is in  
double format for some reason I've forgotten, probably because it was  
easier somewhere.)  Any resemblance to IEEE-754/Decimal is  
coincidental.  And no, I don't know of anybody else having trouble  
with this.  Why can't you connect to the AsmWriter in your code?

More information about the llvm-dev mailing list