www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4765] New: std.math.modf always returns 0

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

           Summary: std.math.modf always returns 0
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: etherous gmail.com



---
The following code should output "3" but instead outputs "0". This is because,
regardless of the values sent to std.math.modf, the returned value is always 0.
I've used many combinations of values, but the result is always the same: 0. At
first I believed I was misusing the function and I noticed that the second
parameter was taken as a ref, so I performed the function call and checked 'b',
but it always stored the beginning value unchanged.

import std.stdio;
import std.math;

void main ()
{
    real a = 9.,
         b = 5.;
    writeln(modf(a,b));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4765




---
Typo: Should return 4, not 3

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4765


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86



---
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't
what's relevant, it's if the app is a 32 or 64 bit app.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4765


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net



13:11:25 PST ---
Actually, I think the documentation is wrong here.  The C function modfl(), to
which std.math.modf() forwards, does not calculate the remainder of an integer
division.  Rather it splits a number into an integer part and a fractional part
(e.g. it splits 3.14 into 3 and 0.14).

The C function to calculate the remainder is fmod(), which doesn't seem to have
a counterpart in std.math.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4765




14:49:18 PST ---
https://github.com/D-Programming-Language/phobos/pull/337

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 28 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4765


Kenji Hara <k.hara.pg gmail.com> changed:

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



https://github.com/D-Programming-Language/phobos/commit/e64089418271072fd7473d86049c1e0213d85eb3

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 03 2011