Re: INTEGER ???
>Rob
>If you are using 31 bits in an Euphoria integer, couldn't this cause a
>compatibility problem when exchanging data with another external program
>because the SIGN BIT does not comform to its standard position ?
>Bernie
Not really...
Euphoria has routines to automatically handle this sort of thing. You just
have to be sure to put the results into a variable of type atom, unless you
KNOW that the value will fit within the bounds for a Euphoria integer. For
example:
atom int32
integer int31
int32 = peek4s (ADDRESS_OF_32_BIT_SIGNED_INT)
-- now you can make use of the 32-bit integer value almost anywhere
int32 = bytes_to_int ({byte1, byte2, byte3, byte4})
-- this is the same thing, except from a sequence instead of from memory;
-- the "int" could be a 32-bit value, so it should be put into an atom
int31 = peek4u (ADDRESS_OF_PLAYER_SCORE_A_32_BIT_UNSIGNED_INT)
-- you could do this if player scores are limited to 0 through 999999
Use poke4() or int_to_bytes() to reverse the process. Other machine-level
routines let you convert between atoms and 32-bit floats, and between atoms
and 64-bit floats.
Rod
|
Not Categorized, Please Help
|
|