Bug 9955 – std.math.feqrel for numbers close to zero
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-04-18T04:46:00Z
Last change time
2013-04-18T06:11:07Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2013-04-18T04:46:11Z
I think feqrel is not working well when numbers are close to 0.0:
import std.stdio: writeln;
import std.math: feqrel;
void main() {
feqrel(1.000000000000001, 1.0).writeln;
feqrel(1.00000000001, 1.0).writeln;
feqrel(1.1, 1.0).writeln;
feqrel(0.000000000000001, 0.0).writeln;
feqrel(0.00000000001, 0.0).writeln;
feqrel(0.1, 0.0).writeln;
}
Prints, dmd 2.063alpha:
50
37
4
0
0
0
Comment #1 by clugdbug — 2013-04-18T06:11:07Z
No, it's correct. They have no equal bits.
What you have is something like this:
0.00000000000000100000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000