[PATCH] Planner: ascent and descent rates should be rounded rather than truncated

Rick Walsh rickmwalsh at gmail.com
Mon Mar 13 13:39:17 PDT 2017


On 14 Mar 2017 5:29 AM, "Jérémie Guichard" <djeBrest at gmail.com> wrote:

Ho!
I didn't realized I used the -Wfloat-conversion on C code only and not C++
when I did my previous round of float/double to int patch!

Looking into that now. There is a bunch of new warnings adding the flag but
seems (at first look) to be managable.

Working on the patch right now...

Excellent!


2017-03-14 0:11 GMT+07:00 Dirk Hohndel <dirk at hohndel.org>:

> On Mon, Mar 13, 2017 at 09:07:31AM -0700, Linus Torvalds wrote:
> > On Mon, Mar 13, 2017 at 12:35 AM, Rick Walsh <rickmwalsh at gmail.com>
> wrote:
> > >
> > >  void PlannerSettingsWidget::setAscRate75(int rate)
> > >  {
> > > -       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate
> * UNIT_FACTOR);
> > > +       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate
> * UNIT_FACTOR + 0.5);
> > >  }
> >
> > These should all definitely use "lrint()" rather than " + 0.5"
> > together with the integer truncation.
>
And that's what happens when a civil engineer tries to teach himself C.
Thanks for showing me the correct way.


> Agreed since UNIT_FACTOR is a floating point number.
>
> Can you send a patch / pull request that does that instead?
>
I would when I found time, which is hard for me at the moment even if it is
just making a simple change to a few lines. Luckily Jérémie has beaten me
to it.

Cheers,

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170314/150aa27d/attachment.html>


More information about the subsurface mailing list