* Re: Question about IIO_DEGREE_TO_RAD macro in include/linux/iio.h
[not found] <CAMHSBOVNOKP=Q32YTL2_vwcW+FfHYNKyOPM4CaesthfoH5xidg@mail.gmail.com>
@ 2015-07-15 23:28 ` Gwendal Grignou
2015-07-16 9:19 ` Lars-Peter Clausen
1 sibling, 0 replies; 3+ messages in thread
From: Gwendal Grignou @ 2015-07-15 23:28 UTC (permalink / raw)
To: Gwendal Grignou; +Cc: lars, linux-iio
[Plain text]
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)
Gwendal.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about IIO_DEGREE_TO_RAD macro in include/linux/iio.h
[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
2015-07-16 17:04 ` Gwendal Grignou
1 sibling, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-07-16 9:19 UTC (permalink / raw)
To: Gwendal Grignou; +Cc: linux-iio
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about IIO_DEGREE_TO_RAD macro in include/linux/iio.h
2015-07-16 9:19 ` Lars-Peter Clausen
@ 2015-07-16 17:04 ` Gwendal Grignou
0 siblings, 0 replies; 3+ messages in thread
From: Gwendal Grignou @ 2015-07-16 17:04 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Gwendal Grignou, linux-iio
Got it, THX,
Gwendal.
On Thu, Jul 16, 2015 at 2:19 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
> 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
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-16 17:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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
2015-07-16 17:04 ` Gwendal Grignou
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.