Linux IIO development
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: linux-iio@vger.kernel.org
Subject: Re: Question about IIO_DEGREE_TO_RAD macro in include/linux/iio.h
Date: Thu, 16 Jul 2015 11:19:22 +0200	[thread overview]
Message-ID: <55A7771A.9020505@metafoo.de> (raw)
In-Reply-To: <CAMHSBOVNOKP=Q32YTL2_vwcW+FfHYNKyOPM4CaesthfoH5xidg@mail.gmail.com>

On 07/16/2015 01:24 AM, Gwendal Grignou wrote:
> Lars,
>
> Looking at the macro IIO_DEGREE_TO_RAD() to translate degree/s into rad/s,
> I don't understand why we add an offset when doing the conversion:
>
> #define IIO_DEGREE_TO_RAD(deg) (((deg) * 314159ULL + 9000000ULL) /
> 18000000ULL)
>
> Shouldn't it just be
> #define IIO_DEGREE_TO_RAD(deg) (((deg) * 314159ULL) / 18000000ULL)

Hi,

The offset is for rounding to the nearest integer. Without the offset it 
would round down.

- Lars



  parent reply	other threads:[~2015-07-16  9:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMHSBOVNOKP=Q32YTL2_vwcW+FfHYNKyOPM4CaesthfoH5xidg@mail.gmail.com>
2015-07-15 23:28 ` Question about IIO_DEGREE_TO_RAD macro in include/linux/iio.h Gwendal Grignou
2015-07-16  9:19 ` Lars-Peter Clausen [this message]
2015-07-16 17:04   ` Gwendal Grignou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A7771A.9020505@metafoo.de \
    --to=lars@metafoo.de \
    --cc=gwendal@chromium.org \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox