Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Injecting tag into mantissa of IEEE floating-point number

Name: Anonymous 2014-04-27 10:25

We all know how it is done for fixnums, but how does one hacks a 64-bit FPU number to snatch a few mantissa bits for a tag? I want it unboxed!

Name: Anonymous 2014-04-27 10:27

We all know how it is done for fixnums
how?

Name: Anonymous 2014-04-27 10:30

>>2
shift left by TAG_BITS

Name: Anonymous 2014-04-27 10:36

Using a tagspace!


double frame_buffer[WIDTH*HEIGHT];
bit is_selected[WIDTH*HEIGHT];

Name: Anonymous 2014-04-27 10:38

>>4

That way one can easily interface with C/C++, becuz everything remains unboxed.

Name: Anonymous 2014-04-27 10:47

You use what's called NaN tagging or NaN boxing. Basically, if all the bits are set in the float's exponent field, it indicates a NaN. At that point you can store whatever you want in the mantissa. With single precision floats you can't do much with the remaining 23 bits, but doubles have 52 bits to play with, more than enough to hold a pointer and a small tag.

The logic is pretty simple: If an atom is a number, then you use it directly. If it's a NaN, you check the tag then mask off the upper bits and use it as you wish.

Name: Anonymous 2014-04-27 10:54

>>4

Alternatively, one can break memory into 2^N sized chunks, putting the corresponding tag into the first byte of every chunk. That way memory address itself would tell the type.

Name: Anonymous 2014-04-27 10:59

>>7 that doesn't help you unbox the doubles, though, which is what >>1-san was asking about.

Name: Anonymous 2014-04-27 12:36

Name: Anonymous 2014-04-27 13:55

x86-64 has a lot of registers, so one could be used to tag all other registers.

Name: Anonymous 2014-04-27 14:11

>>10 That is the stupidest thing I've read today.

Name: Anonymous 2014-04-27 15:03

>>11

Why?

Name: Anonymous 2014-04-28 2:37

>>11
I'd unbox your doubles.

Don't change these.
Name: Email:
Entire Thread Thread List