digitalmars.D - core.math.rndtonl: invalid return type or description?
- ketmar (8/8) Jun 19 2017 core.math.rndtonl is declared as this:
- ag0aep6g (8/11) Jun 19 2017 Is rndtonl a Digital Mars C thing? It has no implementation in druntime,...
- ketmar (6/17) Jun 19 2017 yes, it looks like DMC library function. thus, is should be versioned ou...
- ag0aep6g (6/16) Jun 19 2017 The link covers both. See the Prototype and Description sections.
- ketmar (4/19) Jun 19 2017 ah, sorry, i should really read linked text instead of guessing from the...
- ketmar (3/3) Jun 19 2017 p.s.: it is *important* to use `core.math.rndtonl`! this is compiler
core.math.rndtonl is declared as this: extern (C) real rndtonl(real x); yet it's description says: "...If the integer value of x is greater than long.max, the result is indeterminate." it looks like it either should return `long`, or this part of description was copypasted from `rndtol`. and if it *really* has such limitation, but returns `real`, i think it should be clarified in documentation, 'cause right now it is somewhat confusing.
Jun 19 2017
On 06/19/2017 10:04 AM, ketmar wrote:core.math.rndtonl is declared as this: extern (C) real rndtonl(real x);Is rndtonl a Digital Mars C thing? It has no implementation in druntime, and I get an undefined reference when I try to call it on Linux. It compiles on Windows (wine, -m32), but only ever returns -nan. If this is the same function: <http://www.digitalmars.com/rtl/fltpnt.html#rndtol>, then it should return a C long, which I guess is a D int on 32 bits. And surprise: that works.
Jun 19 2017
ag0aep6g wrote:On 06/19/2017 10:04 AM, ketmar wrote:yes, it looks like DMC library function. thus, is should be versioned out on non-DMC builds. another bug. ;-)core.math.rndtonl is declared as this: extern (C) real rndtonl(real x);Is rndtonl a Digital Mars C thing?It has no implementation in druntime, and I get an undefined reference when I try to call it on Linux. It compiles on Windows (wine, -m32), but only ever returns -nan.If this is the same function: <http://www.digitalmars.com/rtl/fltpnt.html#rndtol>, then it should return a C long, which I guess is a D int on 32 bits. And surprise: that works.no, there is `rndtol()` and `rndtonl()` in `core.math`, they are different functions. also, `rndtol()` should return D `long` (i.e. 64 bit value). at least this is what `core.math` says.
Jun 19 2017
On 06/19/2017 12:45 PM, ketmar wrote:ag0aep6g wrote:[...]The link covers both. See the Prototype and Description sections.If this is the same function: <http://www.digitalmars.com/rtl/fltpnt.html#rndtol>, then it should return a C long, which I guess is a D int on 32 bits. And surprise: that works.no, there is `rndtol()` and `rndtonl()` in `core.math`, they are different functions.also, `rndtol()` should return D `long` (i.e. 64 bit value). at least this is what `core.math` says.Sure, but it doesn't work with D long. It works with D int, which makes sense when the function actually returns a C long (assuming that DMC's long has 32 bits).
Jun 19 2017
ag0aep6g wrote:On 06/19/2017 12:45 PM, ketmar wrote:ah, sorry, i should really read linked text instead of guessing from the name only. ;-)ag0aep6g wrote:[...]The link covers both. See the Prototype and Description sections.If this is the same function: <http://www.digitalmars.com/rtl/fltpnt.html#rndtol>, then it should return a C long, which I guess is a D int on 32 bits. And surprise: that works.no, there is `rndtol()` and `rndtonl()` in `core.math`, they are different functions.then it is yet another bug in `core.math`...also, `rndtol()` should return D `long` (i.e. 64 bit value). at least this is what `core.math` says.Sure, but it doesn't work with D long. It works with D int, which makes sense when the function actually returns a C long (assuming that DMC's long has 32 bits).
Jun 19 2017
p.s.: it is *important* to use `core.math.rndtonl`! this is compiler intrinsic (or at least it should be), and it won't be detected as intrinsic outside of `core.math`.
Jun 19 2017