poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Floating point


From: Jose E. Marchesi
Subject: Re: Floating point
Date: Wed, 12 May 2021 15:08:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Nicholas.

> I've got a bunch of binary data files that contain a mixture of 32 and 64
> bit IEEE 754 floating point values. How can I print the values as a
> formatted decimal?

Poke doesn't support IEEE 754 floating-point values as native values.

The idea is to instead have a iee754.pk pickle containing definitions
for the several supported precision FP numbers, and methods and utility
functions to work with them (like printing their value for example.)

Unfortunately no one has written such a pickle yet, but it sounds like a
fun project :)

This could be a start for ieee754.pk:

type IEEE754_S_FP =
  struct uint<32>
  {
    uint<1> sign;
    uint<8> exponent;
    uint<23> mantissa;

    method denormalised_p = int<32>:
    {
      return exponent == 0 && mantissa != 0;
    }

    method is_inf = int<32>:
    {
      return exponent == 0xff && mantissa == 0;
    }

    method is_nan = int<32>:
    {
      return (exponent == -1 as uint<8>
              && (sign == 0 || mantissa != 1 <<. 22);
    }

    /* More methods... */
  };



reply via email to

[Prev in Thread] Current Thread [Next in Thread]