Several float to int potential rounding errors/inconsistencies

Lubomir I. Ivanov neolit123 at gmail.com
Tue Mar 7 09:20:53 PST 2017


On 7 March 2017 at 19:11, Linus Torvalds <torvalds at linux-foundation.org> wrote:
> On Mon, Mar 6, 2017 at 8:50 PM, Linus Torvalds
> <torvalds at linux-foundation.org> wrote:
>>
>> Ugh, yes. Mainly because it warns even about the "cast rint() to an
>> integer" case:
>
> Actually, the correct thing to do is to use lrint(), but my very dim
> memory is that this didn't work on Windows.
>
> Dirk (or anybody else with a Windows build), does this build:
>
>     git grep -l '\<rint(' | xargs sed -i 's/rint(/lrint(/g'
>
> it just replaces 'rint()" calls with 'lrint()'.
>
> If it does build, you should just commit it. Otherwise we'd need some
> Windows helper macro to implement it, possibly just
>
>    #ifdef WIN32
>     #define lrint(x) ((long)rint(x))
>    #endif
>
> or similar.
>
> That gets rid of the worst noise, and leaves just real (but admittedly
> likely not very important) float->integer conversion warnings.
>

lrint() seems to build for me with mingw 4.9.2.
if it works for Dirk's Windows build, then its good to go.

lubomir
--


More information about the subsurface mailing list