poke8 problems : 64-bit numbers in a 53-bit language
- Posted by SDPringle Sep 26, 2015
- 1700 views
Euphoria on 32-bit machines has a problem. We use 64-bit values on a 53-bit number language. Now numbers like -1, which as a signed 64-bit number is 0xffff_ffff_ffff_ffff. You can poke -1 with poke8, but that number is actually a 32 bit value so no problem. You can even poke values such as 0xffff_ffff_ffff_f800 with poke8 on a 32-bit system. As soon as you employ things like numbers that cannot be represented in a double exactly, the number in the backend becomes 0.
The difference is if the number you use cannot be represented exactly in a eudouble, then the value becomes zero before it gets a chance to be written to memory.
The user has to avoid this kind of thing. It rather makes sense not to allow you to write a number when the value is imprecise. At the same time, writing 0 rather than what the user supplied is just wrong. It seems to be that this should be an error condition. It must be documented and caught by the backend.
SD Pringle