Thread overview
[Issue 5323] std.math: struct FloatingPointControl, duplicate code and assumes X86
Nov 01, 2015
Infiltrator
Nov 01, 2015
Iain Buclaw
Nov 01, 2015
Iain Buclaw
Mar 03, 2017
Guillaume Chatelet
Feb 10, 2018
Iain Buclaw
Dec 17, 2022
Iain Buclaw
November 01, 2015
https://issues.dlang.org/show_bug.cgi?id=5323

Infiltrator <lt.infiltrator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lt.infiltrator@gmail.com

--- Comment #2 from Infiltrator <lt.infiltrator@gmail.com> ---
Is this still an issue?  I'd have a look at the source, but I'm afraid that I wouldn't be able to tell what's X86 or SPARC, etc.

--
November 01, 2015
https://issues.dlang.org/show_bug.cgi?id=5323

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Infiltrator from comment #2)
> Is this still an issue?  I'd have a look at the source, but I'm afraid that I wouldn't be able to tell what's X86 or SPARC, etc.

Well, X86 code is guarded by a version(X86) block, SPARC code by a
version(SPARC) block.  :-)

--
November 01, 2015
https://issues.dlang.org/show_bug.cgi?id=5323

--- Comment #4 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Both struct FloatingPointControl and Ieeeflags still have their own private enums.  Since these values should be mirrored somewhere in druntime stdc (it looks like the me of five years ago couldn't work out where when searching through the libc headers), then yes this is still a valid refactoring.

--
March 03, 2017
https://issues.dlang.org/show_bug.cgi?id=5323

Guillaume Chatelet <chatelet.guillaume@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chatelet.guillaume@gmail.co
                   |                            |m

--- Comment #5 from Guillaume Chatelet <chatelet.guillaume@gmail.com> ---
It seems to me that setting rounding mode and testing for inexact does not work correctly on x86_64.

Correct code using the C bindings:
void main() {
    import core.stdc.fenv;
    fesetround(FE_UPWARD);
    float x = 1.0f;
    x += float.min_normal;
    writefln("%.32g, inexact: %s", x, fetestexcept(FE_INEXACT) > 0);
}

> Output: 1.00000011920928955078125, inexact: true

The same code using FloatingPointControl and IeeeFlags does not work at all
(neither set round nor test except)
void main() {
    resetIeeeFlags();
    FloatingPointControl fpctrl;
    fpctrl.rounding = FloatingPointControl.roundUp;
    float x = 1.0f;
    x += float.min_normal;
    writefln("%.32g, inexact: %s", x, ieeeFlags.inexact);
}

> Output: 1, inexact: false

Linked discussion: http://forum.dlang.org/post/qybweycrifqgtcssepgx@forum.dlang.org

--
February 10, 2018
https://issues.dlang.org/show_bug.cgi?id=5323

--- Comment #6 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Has been improved somewhat by:

https://github.com/dlang/phobos/pull/4272 https://github.com/dlang/phobos/pull/5769

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=5323

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--