Thread overview |
---|
June 19, 2017 core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
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. |
June 19, 2017 Re: core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | 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. |
June 19, 2017 Re: core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | ag0aep6g wrote: > 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? yes, it looks like DMC library function. thus, is should be versioned out on non-DMC builds. another bug. ;-) > 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. |
June 19, 2017 Re: core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | 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`. |
June 19, 2017 Re: core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | On 06/19/2017 12:45 PM, ketmar wrote: > ag0aep6g wrote: [...] >> 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. The link covers both. See the Prototype and Description sections. > 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). |
June 19, 2017 Re: core.math.rndtonl: invalid return type or description? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | ag0aep6g wrote: > On 06/19/2017 12:45 PM, ketmar wrote: >> ag0aep6g wrote: > [...] >>> 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. > > The link covers both. See the Prototype and Description sections. ah, sorry, i should really read linked text instead of guessing from the name only. ;-) >> 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). then it is yet another bug in `core.math`... |
Copyright © 1999-2021 by the D Language Foundation