Re: [PATCH v11 10/15] iio: afe: rescale: make use of units.h

Andy Shevchenko
2021-12-22T19:01:21Z

On Wed, Dec 22, 2021 at 8:51 PM Liam Beguin <liambeguin@gmail.com> wrote:
> On Wed, Dec 22, 2021 at 02:33:52PM +0200, Andy Shevchenko wrote:
> > On Wed, Dec 22, 2021 at 5:47 AM Liam Beguin <liambeguin@gmail.com> wrote:

...

> > Thanks! The important part of this conversion is to get one trick,
> > i.e. NANO and GIGA are both represented by 10^9. We need to be sure
> > that here we use the proper sign of the power of these numbers. So
> > please double check in all cases that the chosen SI prefixes are
> > correct from the power sign point of view, e.g. it is 10^-9 and not
> > 10^9 or otherwise.
>
> I get the difference, but I guess I'm not sure I understand how you want me to
> use them. I was using NANO here as that made most sense for me.
>
> If we go by the positive vs. negative powers of ten, I should always use
> GIGA as we're multiplying by 10^9 and dividing by 10^9. Is that what you
> expected?

You should get the proper power after the operation.
Write a formula (mathematically speaking) and check each of them for this.

10^-5/10^-9 == 1*10^4 (Used NANO)
10^-5/10^9 == 1/10^-14 (Used GIGA)

See the difference?

In the similar way for values of e.g. 10^5.

--
With Best Regards,
Andy Shevchenko