[LLVMdev] APFloat::convertToDouble asserts

Dale Johannesen dalej at apple.com
Fri Jul 9 13:42:23 PDT 2010


On Jul 9, 2010, at 1:20 PMPDT, Jochen Wilhelmy wrote:
>> I'd rather not.  The functionality you want is there, feed another  
>> APFloat type through APFloat::convert first.
>>
>> Using host FP is not something that should be encouraged; the main  
>> point of APFloat is so people don't have to do that.  Why do you  
>> want to, btw?
>
> Yes, i got it working using APFloat::convert. I need host float to  
> output to my backend which is similar
> to the c-backend, but generates if/else instead of goto. I do not  
> use APFloat::toString since it can
> generate "1" for 1.0 which is not useful for me since I append "f"  
> for float and "1f" is not a valid float.

I'm not sure converting to decimal is the way to go for that.  What  
are you planning to do about NaNs?
Something like this would handle all cases:

union { int x; float f; } u = { 0x7f.... };
u.f




More information about the llvm-dev mailing list