Bug 18559 – std.math.* should stop using `real` overloads by default

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2018-03-05T20:09:22Z
Last change time
2024-12-01T16:32:58Z
Assigned to
No Owner
Creator
hsteoh
See also
https://issues.dlang.org/show_bug.cgi?id=24040
Moved to GitHub: phobos#10318 →

Comments

Comment #0 by hsteoh — 2018-03-05T20:09:22Z
Using 80-bit reals on x86 causes major performance degradations in std.math functions like atan(). This poor performance is on the brink of turning away a significant group of potential D users, and needs to be taken seriously: Cf.: https://forum.dlang.org/post/[email protected] It's about time we take off our blinders and stop pretending that 80-bit "extra" precision buys us anything. Let 80-bit be an option if the user wants to, sure. But can we please, pretty please, change the default type in std.math.* to double instead of real. This is making our "fast code fast" slogan look absolutely ridiculous when people run benchmarks like that linked to above, and see D performing horribly slow compared to C++.
Comment #1 by kinke — 2018-03-05T22:44:34Z
(In reply to hsteoh from comment #0) > Let 80-bit be an option if the user > wants to, sure. But can we please, pretty please, change the default type > in std.math.* to double instead of real. Performing the operation in the precision of the operands is what I'd expect. So having to cast explicitly to real if my data is stored as float/double and max precision is needed. Some math functions are still only implemented for `real`, but they support reals in double/x87/quadruple precision for the different architectures, i.e., support for 64-bit doubles (proper constants, limits etc.) is already there. E.g., std.math.atan(real) could be generalized to a template (float/double/real) after adding single-precision support (from Cephes probably).
Comment #2 by iamthewilsonator — 2018-03-11T01:38:19Z
Comment #3 by pro.mathias.lang — 2021-01-09T22:34:14Z
*** Issue 19712 has been marked as a duplicate of this issue. ***
Comment #4 by john.michael.hall — 2022-05-11T02:17:21Z
I would add to this the functions in std.mathspecial, which are only defined for reals.
Comment #5 by robert.schadek — 2024-12-01T16:32:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10318 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB