Hi!
I wonder why APFloat::convertToDouble asserts if it is not an
APFloat::IEEEdouble while the name "convertToDouble" suggests that it
converts when it is not a double.
-Jochen
Hi!
I wonder why APFloat::convertToDouble asserts if it is not an
APFloat::IEEEdouble while the name "convertToDouble" suggests that it
converts when it is not a double.
-Jochen
The conversion is to (host) double, as the name implies. Among APFloat types, that is only implemented for APFloat::IEEEdouble.
I wonder why APFloat::convertToDouble asserts if it is not an
APFloat::IEEEdouble while the name "convertToDouble" suggests that it
converts when it is not a double.The conversion is to (host) double, as the name implies. Among APFloat types, that is only implemented for APFloat::IEEEdouble.
yes, it's to host double ("convert this APFloat to double"), therefore I hoped that it works for any APFloat type (otherwise I would suggest a name such as getIfIEEEdouble() ).
Is there a reason against it or would it be accepted if it would work for any type?
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?
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.
-Jochen
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
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
currently NaN's simply do not occur as I do not allow full featured c++ code as input. I have my own
double to string function which could handle NaN if necessary. it then should output a string like
"std::numeric_limits<double>::quiet_NaN()"