[Ecls-list] ECL's view of floats

Lars Brinkhoff lars at nocrew.org
Sun Aug 13 18:01:51 UTC 2006


Thanks for answering!

Juan Jose Garcia-Ripoll wrote:
> Lars Brinkhoff wrote:
> > I'm working on a patch to convert ECL to the single/double-float
> > style, and also to add a third immediate short-float type.
> The first part is ok with me

Good.  I'll keep working on that, then.

> but I don t understand that with the immediate short-float type.

You are absolutely right that's it's of questionable benefit.  Right
now, I'm doing it mostly for fun, and I'm not saying it should
necessarily go in the official ECL distribution.

Note that CLISP has immediate short-floats, so they may be good for
something.  See more at the bottom of this message.

At worst, they could be a compile-time (ECL build compile-time, that
is) option.  How about that?

> What machine data-type will it correspond to?

On a 32-bit machine, it will correspond to a 32-bit float, minus 2
bits.

Maybe code explains it best:

    cl_object make_immediate_shortfloat (float x)
    {
      cl_fixnum y = *(cl_fixnum *)&x;   /* Get the raw float bits. */
      y &= ~IMMEDIATE_TAG;              /* Mask off bottom two bits. */
      y |= IMMEDIATE_SHORTFLOAT_TAG;    /* Add type tag = 3. */
      return (cl_object)y;
    }

Instead of plain masking, there could be some kind of rounding.

> If it is if the same size and accuracy as the other types, I do not
> see the need to enlarge the core image with a redundant type.

Pros:
 - Cool feature?  Maybe I'm the only one thinking that.
 - Non-consing float calculations, which may be faster?
 - 64-bit machines could have immediate 32-bit floats anyway, and this
   patch would clear the way for that.

Cons:
 - Bloats the image.
 - Slows down FIXNUMP and CHARACTERP.





More information about the ecl-devel mailing list