std.math: Add RealRep union for accessing floating point bits via a union.#5825
std.math: Add RealRep union for accessing floating point bits via a union.#5825ibuclaw wants to merge 4 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#5825" |
7bd4423 to
a61bcbc
Compare
|
Unless someone has added floating-point It could be re-written to emulate a I think the compiler team needs to pick a long-term solution to the floating-point CTFE issue before it's worth refactoring |
I don't particularly buy that, as many functions that do pointer casting are not CTFE-able anyway. Typical getter/setters look like this. The value of |
|
Specifically, this will break import std.math, std.stdio;
void main() {
enum float x = float.nan;
enum a = isInfinity(x);
enum b = isNaN(x);
writeln(a, ", ", b);
enum double y = double.infinity;
enum c = isInfinity(y);
enum d = isNaN(y);
writeln(c, ", ", d);
}Admittedly, these can both be reimplemented in a CTFE-compatible way by the user easily enough: bool isInfinity(X)(X x) { return x > X.max || x < -X.max; }
bool isNaN(X)(X x) { return x != x; }But, it is still a breaking change. If that's considered acceptable, then why not just go with my original pull request? |
|
I'm in the middle of testing ieeeQuadruple and ibmExtended, and finding bugs in both. I'd want to make sure that is complete before introducing yours. To make sure we start from a working implementation before the redesign. |
|
That makes sense. |
|
ping @ibuclaw Please rebase? |
|
Rebased. |
|
@ibuclaw maybe it's better if you rebase yourself this time? |
|
Rebased, but I'll have to double-check that ibmExtended is still fine (did some educated guesswork on reimplementing the floorImpl I added in the new format). |
|
@ibuclaw would need another rebase. |
|
PR closed as stalled. @thewilsonator would like to split this into two PR's. One for the new feature and another for the refactoring. |
As I'd like to see this move forwards, but am in the middle of finishing up work on new ports (making sure that 128-bit is working properly for both IEEE and IBM reals) so can't really commit at the moment.
This is a slightly more conservative version of #4336. As far as I can see, GDC at least produces identical assembly in the conversion from old to new.
Should allow the bigger refactorings in the other PR to be added gracefully. @tsbockman - would you agree?