www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9955] New: std.math.feqrel for numbers close to zero

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9955

           Summary: std.math.feqrel for numbers close to zero
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 18 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9955


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



No, it's correct. They have no equal bits.

What you have is something like this:
0.00000000000000100000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 18 2013