Re: Several float to int potential rounding errors/inconsistencies

2017-03-11 Thread Lubomir I. Ivanov
On 11 March 2017 at 17:24, Dirk Hohndel wrote: > On Sat, Mar 11, 2017 at 03:41:53PM +0200, Lubomir I. Ivanov wrote: >> On 11 March 2017 at 07:21, Jérémie Guichard wrote: >> > Hey guys, >> > >> > I've added the flag conditionally as discussed in previous

Re: Several float to int potential rounding errors/inconsistencies

2017-03-11 Thread Lubomir I. Ivanov
On 11 March 2017 at 18:32, Linus Torvalds wrote: > On Sat, Mar 11, 2017 at 5:41 AM, Lubomir I. Ivanov > wrote: >> >> of course, there is no need of lrint() in a lot of locations and >> rint() can be used instead, like here: >> >> -

Re: Several float to int potential rounding errors/inconsistencies

2017-03-11 Thread Linus Torvalds
On Sat, Mar 11, 2017 at 5:41 AM, Lubomir I. Ivanov wrote: > > of course, there is no need of lrint() in a lot of locations and > rint() can be used instead, like here: > > - sample->depth.mm = depth * FEET * 1000; > + sample->depth.mm = lrint(depth * FEET * 1000); > > "mm" is

Re: Several float to int potential rounding errors/inconsistencies

2017-03-11 Thread Dirk Hohndel
On Sat, Mar 11, 2017 at 03:41:53PM +0200, Lubomir I. Ivanov wrote: > On 11 March 2017 at 07:21, Jérémie Guichard wrote: > > Hey guys, > > > > I've added the flag conditionally as discussed in previous mail, and updated > > the pull request. > > i've tested the changes locally

Re: Several float to int potential rounding errors/inconsistencies

2017-03-11 Thread Lubomir I. Ivanov
On 11 March 2017 at 07:21, Jérémie Guichard wrote: > Hey guys, > > I've added the flag conditionally as discussed in previous mail, and updated > the pull request. i've tested the changes locally on Windows and it builds fine. llrint() is also available. 4.9.0 seems to be

Re: Several float to int potential rounding errors/inconsistencies

2017-03-10 Thread Jérémie Guichard
Hey guys, I've added the flag conditionally as discussed in previous mail, and updated the pull request. Meanwhile I was able to fix the failure in TestPreferences (in a separate pull request). Once both are merged, all tests will be passing on Windows/wine. Yuhu! I'm not familiar with Travis at

Re: Several float to int potential rounding errors/inconsistencies

2017-03-08 Thread Dirk Hohndel
On Wed, Mar 08, 2017 at 02:42:28PM +0700, Jérémie Guichard wrote: > > Unfortunately I could not enable the flag in that commit since travis seems > to be using gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 that do not include > this option... Nevertheless it may be a good idea to make use of the

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Jérémie Guichard
Hey guys, Thanks for the help on this topic! I have now updated my pull request with the different proposed changes. The first commit changes all rint to lrint. Based on Lubomir recommendation, I went through the different places to check (and use) lrintf where necessary. Doing so I found two

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Jérémie Guichard
I'm looking into that right now :) 2017-03-08 7:18 GMT+07:00 Dirk Hohndel : > On Tue, Mar 07, 2017 at 09:43:06AM -0800, Linus Torvalds wrote: > > On Tue, Mar 7, 2017 at 9:20 AM, Lubomir I. Ivanov > wrote: > > > > > > lrint() seems to build for me with

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Dirk Hohndel
On Tue, Mar 07, 2017 at 09:43:06AM -0800, Linus Torvalds wrote: > On Tue, Mar 7, 2017 at 9:20 AM, Lubomir I. Ivanov wrote: > > > > lrint() seems to build for me with mingw 4.9.2. > > .. in fact, I notice that we had a couple of places in the GPS > coordinates code that

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Linus Torvalds
On Tue, Mar 7, 2017 at 9:20 AM, Lubomir I. Ivanov wrote: > > lrint() seems to build for me with mingw 4.9.2. .. in fact, I notice that we had a couple of places in the GPS coordinates code that already used 'lrint()', so it must work. The uemis code has a few places that

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Lubomir I. Ivanov
On 7 March 2017 at 19:11, Linus Torvalds wrote: > On Mon, Mar 6, 2017 at 8:50 PM, Linus Torvalds > wrote: >> >> Ugh, yes. Mainly because it warns even about the "cast rint() to an >> integer" case: > > Actually, the correct thing to

Re: Several float to int potential rounding errors/inconsistencies

2017-03-07 Thread Linus Torvalds
On Mon, Mar 6, 2017 at 8:50 PM, Linus Torvalds 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

Re: Several float to int potential rounding errors/inconsistencies

2017-03-06 Thread Linus Torvalds
On Mon, Mar 6, 2017 at 8:50 PM, Linus Torvalds wrote: > On Mon, Mar 6, 2017 at 8:27 PM, Linus Torvalds > wrote: >> >> Hmm. I guess there's "-Wfloat-conversion". It might cause excessive >> warnings. I'll try. > > Ugh, yes. Mainly

Re: Several float to int potential rounding errors/inconsistencies

2017-03-06 Thread Linus Torvalds
On Mon, Mar 6, 2017 at 8:27 PM, Linus Torvalds wrote: > > Hmm. I guess there's "-Wfloat-conversion". It might cause excessive > warnings. I'll try. Ugh, yes. Mainly because it warns even about the "cast rint() to an integer" case: core/units.h: In function

Re: Several float to int potential rounding errors/inconsistencies

2017-03-06 Thread Linus Torvalds
On Mon, Mar 6, 2017 at 8:23 PM, Linus Torvalds wrote: > > I'd love to have some way to automatically find the places where we do > that "implicit cast from FP to int without proper rounding", but I > don't know of any such tool (sparse could be modified to do it,

Re: Several float to int potential rounding errors/inconsistencies

2017-03-06 Thread Linus Torvalds
On Mon, Mar 6, 2017 at 7:59 PM, Dirk Hohndel wrote: > > Any other opinions on how to do this? I'm actually rather surprised that > Linus hasn't spoken up. He must be busy with the merge window of that > earlier, less interesting open source project he is involved in... I

Re: Several float to int potential rounding errors/inconsistencies

2017-03-06 Thread Dirk Hohndel
On Sun, Mar 05, 2017 at 07:03:01PM +0200, Lubomir I. Ivanov wrote: > On 5 March 2017 at 09:36, Jérémie Guichard wrote: > > Good morning/afternoon/evening all, > > > > I've been lately trying to get subsurface tests to pass under windows. In > > the current state, TestParse and

Re: Several float to int potential rounding errors/inconsistencies

2017-03-05 Thread Lubomir I. Ivanov
On 5 March 2017 at 09:36, Jérémie Guichard wrote: > Good morning/afternoon/evening all, > > I've been lately trying to get subsurface tests to pass under windows. In > the current state, TestParse and TestPreferences are the two ones still > failing... > > In short, the error

Several float to int potential rounding errors/inconsistencies

2017-03-04 Thread Jérémie Guichard
Good morning/afternoon/evening all, I've been lately trying to get subsurface tests to pass under windows. In the current state, TestParse and TestPreferences are the two ones still failing... In short, the error raised by TestParse is caused by a rounding error when converting dm4 sample depth