linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Othacehe <m.othacehe@gmail.com>
To: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
Cc: linux-iio@vger.kernel.org, lars@metafoo.de
Subject: Re: Mostly question of whether we should support floating point values from hardware (was Re: isl29501 and multiple calibration registers)
Date: Wed, 27 Jun 2018 15:43:38 +0200	[thread overview]
Message-ID: <87vaa4tkdx.fsf@gmail.com> (raw)
In-Reply-To: <20180616184626.24789092@archlinux>


Hi Jonathan,

> https://en.wikipedia.org/wiki/Double-precision_floating-point_format.
>
> So in rough form...
>
> fls('mantissa') will get us the most significant set bit. 
> Shift the mantissa so that falls off the top and add that shift
> to the exponent. 
>
> Poke in the right places in a standard double.

Yes, understood, this way we can format Intersil float representation
(m*2^e) to IEEE754 (1.m*2^e).

> Now this is where it gets even uglier.   IIO assumes 2 32 bit
> parts so we'll need to mash it into those in some reasonable
> (ish) fashion.  The core IIO then needs to pretty print it.

An option would be to add IIO_VAL_DOUBLE format value that would print
ieee754 double in a similar way as '%a' option of glibc' printf
([-]0xh.hhhhp).

A "iio_double_to_int" function would also be needed to parse a user
inputed number under '%a' representation into two 'int' passed to
write_raw.

> Hmm. This looks annoyingly like we may need to do some core
> rework to make val and val2 64 bit relatively soon but I'd
> rather we didn't stall this driver on that.

Yes the splitting would be really ugly as the mantissa on 52 bit will
have to be splitted in two parts, something like:

val: sign | exponent | mantissa (20 most valuable bits)
val2: mantissa (32 last bits)

Or something as dirty as that ...

All of this seems really hacky but would allow user to input big
floating values (that won't fit into val.val2 format with val and val2
on 32 or even 64 bit format).

What do you think ?

Thanks,

Mathieu

  reply	other threads:[~2018-06-27 13:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:01 isl29501 and multiple calibration registers Mathieu Othacehe
2018-05-27  8:59 ` Jonathan Cameron
2018-05-28 15:38   ` Mathieu Othacehe
2018-06-03 14:38     ` Jonathan Cameron
2018-06-05 10:18       ` Mathieu Othacehe
2018-06-10 13:29         ` Jonathan Cameron
2018-06-11 14:57           ` Mathieu Othacehe
2018-06-15 12:34             ` Mathieu Othacehe
2018-06-16 17:46               ` Mostly question of whether we should support floating point values from hardware (was Re: isl29501 and multiple calibration registers) Jonathan Cameron
2018-06-27 13:43                 ` Mathieu Othacehe [this message]
2018-06-30 17:55                   ` Jonathan Cameron
2018-06-16 17:13             ` isl29501 and multiple calibration registers Jonathan Cameron
2018-06-19 10:24               ` Mathieu Othacehe

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=87vaa4tkdx.fsf@gmail.com \
    --to=m.othacehe@gmail.com \
    --cc=jic23@jic23.retrosnub.co.uk \
    --cc=lars@metafoo.de \
    --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;
as well as URLs for NNTP newsgroup(s).