Bug 9742 – std.math.floor returns 0 for any value x > -1 and x < 0
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-17T11:39:00Z
Last change time
2013-05-27T14:00:39Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2013-03-17T11:39:26Z
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);
}
Comment #1 by clugdbug — 2013-04-22T23:50:42Z
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?
Comment #2 by code — 2013-05-08T06:31:13Z
Yes happend to me on Windows, might be platform specific.
Comment #3 by galtiberiu — 2013-05-26T14:14:59Z
it works on windows
Comment #4 by andrei — 2013-05-27T08:04:24Z
Can Tiberiu or somebody else confirm this works on Win32/64 with the latest beta? Thanks!
Comment #5 by galtiberiu — 2013-05-27T08:54:12Z
I can only test it with win32. It works with the latest beta.
(OT: Is there any easy way to test win64?)
Comment #6 by mike — 2013-05-27T11:00:09Z
It works for me under Windows with the latest beta.
Both the 32 and 64 bits version are working.
Comment #7 by bearophile_hugs — 2013-05-27T11:54:34Z
(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.
Comment #8 by bus_dbugzilla — 2013-05-27T12:42:25Z
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".