Thread overview
[Issue 9742] New: std.math.floor returns 0 for any value x > -1 and x < 0
Mar 17, 2013
Benjamin Thaut
Apr 23, 2013
Don
May 08, 2013
Benjamin Thaut
May 26, 2013
Tiberiu Gal
May 27, 2013
Tiberiu Gal
May 27, 2013
Mike Wey
May 27, 2013
Nick Sabalausky
March 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742

           Summary: std.math.floor returns 0 for any value x > -1 and x <
                    0
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@benjamin-thaut.de


--- Comment #0 from Benjamin Thaut <code@benjamin-thaut.de> 2013-03-17 11:39:26 PDT ---
The documentation says that std.math.floor

Returns the value of x rounded downward to the next integer (toward negative
infinity).

But it returns 0 for any value x > -1 and x < 0. This used to work correctly in earlier versions of phobos.

Repro case:

import std.math;
import core.stdc.stdio;

void main(string[] args)
{
    assert(std.math.floor(-0.002f) == -1.0f);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2013-04-22 23:50:42 PDT ---
Using current git DMD and Phobos, works for me on D2 Linux with both 32 bit and
64bit, with and without -O.
Perhaps this is OS-specific. Can you give more details?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742



--- Comment #2 from Benjamin Thaut <code@benjamin-thaut.de> 2013-05-08 06:31:13 PDT ---
Yes happend to me on Windows, might be platform specific.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742


Tiberiu Gal <galtiberiu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |galtiberiu@gmail.com


--- Comment #3 from Tiberiu Gal <galtiberiu@gmail.com> 2013-05-26 14:14:59 PDT ---
it works on windows

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com


--- Comment #4 from Andrei Alexandrescu <andrei@erdani.com> 2013-05-27 08:04:24 PDT ---
Can Tiberiu or somebody else confirm this works on Win32/64 with the latest beta? Thanks!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742



--- Comment #5 from Tiberiu Gal <galtiberiu@gmail.com> 2013-05-27 08:54:12 PDT ---
I can only test it with win32. It works with the latest beta. (OT: Is there any easy way to test win64?)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742


Mike Wey <mike-wey@planet.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mike-wey@planet.nl


--- Comment #6 from Mike Wey <mike-wey@planet.nl> 2013-05-27 11:00:09 PDT ---
It works for me under Windows with the latest beta.

Both the 32 and 64 bits version are working.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bearophile_hugs@eml.cc
         Resolution|                            |WORKSFORME


--- Comment #7 from bearophile_hugs@eml.cc 2013-05-27 11:54:34 PDT ---
(In reply to comment #6)
> It works for me under Windows with the latest beta.
> 
> Both the 32 and 64 bits version are working.

I have only tried it on 32 bit. If you have tried it on 64 bit, then let's close this down.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742


Nick Sabalausky <cbkbbejeap@mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cbkbbejeap@mailinator.com
         Resolution|WORKSFORME                  |FIXED


--- Comment #8 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2013-05-27 12:42:25 PDT ---
It works for me on Win32 with both 2.062 and the latest beta, when using no cmdline switches, and also when using "-O -inline -noboundscheck".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9742



--- Comment #9 from Andrei Alexandrescu <andrei@erdani.com> 2013-05-27 14:00:39 PDT ---
Great, thanks everyone for chiming in!

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