Thread overview
[Issue 4765] New: std.math.modf always returns 0
Aug 30, 2010
Brandon Lyon
Aug 30, 2010
Brandon Lyon
Feb 06, 2011
Brad Roberts
Dec 03, 2011
Kenji Hara
August 30, 2010
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


--- Comment #0 from Brandon Lyon <etherous@gmail.com> 2010-08-29 19:31:16 PDT ---
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: -------
August 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4765



--- Comment #1 from Brandon Lyon <etherous@gmail.com> 2010-08-29 19:33:57 PDT ---
Typo: Should return 4, not 3

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4765


Brad Roberts <braddr@puremagic.com> changed:

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


--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2011-02-06 15:39:56 PST ---
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: -------
November 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4765


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

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


--- Comment #3 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2011-11-15 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: -------
November 28, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4765



--- Comment #4 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2011-11-28 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: -------
December 03, 2011
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


--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-03 06:47:31 PST ---
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: -------