Re: Eu integers [was eternity]

new topic     » topic index » view thread      » older message » newer message

Alex Caracatsanis wrote:
> 
> Jason Gade wrote:
> > 
> > Euphoria uses 31-bit integers instead of 32-bit, which effectively cuts the
> > integer range in half. But it's still approximately +/- 1 billion or so.
> > 
> > The most significant bit is used as a flag to tell whether the value is an
> > integer
> > or a pointer to either an atom or a sequence.
> > 
> 
> Jason, in Eu is "the most signifiacant bit" the 31st bit or the 32nd bit?
> Also, how does Eu indicate whether the integer is positive or negative?

Rob was actually very clever in how euphoria determines data types.  I've
pasted in the comments from execute.h, which show what different bit
patterns mean to the interpreter.  For doubles and sequences, Rob has
made sure that they are always allocated so that the pointer is a 
multiple of 8.  That means that he always has an extra 3 buts where he
can store whatever he wants.

So certain patterns are reserved for indicating pointers to a double,
and others indicate a pointer to a sequence, etc.  Given how twos complement
arithmetic is implemented on x86, he only cuts off the really large 
magnitude (both positive and negative) integers.

    unused  : 011xxxxx xxxxxxxx xxxxxxxx xxxxxxxx 
    unused  : 010xxxxx xxxxxxxx xxxxxxxx xxxxxxxx

    TOO_BIG:  01000000 00000000 00000000 00000000   (just too big for INT)
	
    +ATOM-INT: 001vvvvv vvvvvvvv vvvvvvvv vvvvvvvv   (31-bit integer value)
    +ATOM-INT: 000vvvvv vvvvvvvv vvvvvvvv vvvvvvvv   (31-bit integer value)
    -ATOM-INT: 111vvvvv vvvvvvvv vvvvvvvv vvvvvvvv   (31-bit integer value)
    -ATOM-INT: 110vvvvv vvvvvvvv vvvvvvvv vvvvvvvv   (31-bit integer value)

    NO VALUE: 10111111 11111111 11111111 11111111   (undefined object)

    ATOM-DBL: 101ppppp pppppppp pppppppp pppppppp   (29-bit pointer)

    SEQUENCE: 100ppppp pppppppp pppppppp pppppppp   (29-bit pointer)

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu