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
fix Issue 22740 - float and double literals should be rounded to thei… #13613
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using native types won't work for emulated floating point. This operation should really go via CTFloat, so that each compiler (or longdouble type) can implement it in the correct way for them.
I'm not sure why it wouldn't work. The D spec requires |
Thanks for your pull request, @WalterBright! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#13613" |
d09362b
to
bb2df35
Compare
It appears that CTFloat cannot currently convert to float or double. I've been considering writing an 80 bit emulator, it seems this PR will have to wait for that. |
I haven't been able to find online a Boost compatible 80 bit emulator. |
But the longdouble implementation is not necessarily There's a reason why I've been periodically changing |
Ah, so it isn't just gdc that emulates a float then judging from the Win64 failures. Good to know. |
Can't you just add a CTFloat.truncate function, rather than go the whole hog? |
This looks inferior to #11387 to me - parsing the literals as And AFAICT it doesn't address the concerns raised in my PR. |
I think all Lines 169 to 191 in 27d052e
|
That only works because the underlying layout matches native reals though. Which isn't the case for me. |
So IIUC, the type you are using cannot be simply converted to a native double or float?! I know for a fact that LLVM's |
I see The number of times a float or double appears in gdc is zero, so it would be good to keep it that way. |
bb2df35
to
24b2251
Compare
e3dbf8e
to
1c2bda4
Compare
…r precision
As @ibuclaw pointed out, this can be forced already with core.math.toPrec, but I suspect that making enum, const, and static all produce the same value should be unsurprising.