-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert double to ConstantFP #122851
Comments
You can use it if the It's a bit weird for a compiler to create a constant like that that's an arbitrary value that didn't appear in the source. I think that's the primary reason for that comment. A compiler might turn A+A into A*2.0 where it would need to create the 2.0 constant that didn't exist. |
Thank you for your suggestion 😄! I tried following snippet
When I dump Ret, i get
From what I understand, this hex value is IEEE 754 standard representation for 233.33000183105469. This is semantic correct, but I want this Any ideas 🤔 ? |
ConstantFP internally stores its data using |
Thank you for clarification. I checked
This outputs
It seems there is still a gap/mismatch between |
I want to generate ConstantFP using C++ double. For some reasons, the double is obtained in runtime, and it may not suits “simple constant value”
For example, i have a double 233.33, in runtime, the IEEE 754 representation is 0x406D2A8F60000000, if I print it, it is 233.33000183105469. Check IEEE 754 calculator for fun. I know floating point is not continuous, so some values may not have exact representation in IEEE 754 standard. They are encoded to nearest valid doubles instead.
I want to keep some fractional part, so rounding is not enough. But by sacrificing some precision, can I convert my double to
ConstantFP
?The text was updated successfully, but these errors were encountered: