BBC BASIC for Windows
Programming >> BBC BASIC language >> *HEX64 is useful... http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1438331719 *HEX64 is useful...
Post by DDRM on Jul 31st, 2015, 08:35am
Just a note about something that caught me out, and might help others...
If you use the new 64 bit integers, (for example, bigint%%), some operation may not work as you expect if you forget to issue a *HEX64 command first!
Examples: Code:
bigint%%=&FFFFFFFF
will set bigint%% to -1, while Code:
*HEX64
bigint%%=&FFFFFFFF
will (correctly) set it to 4294967295.
The one that got me was that PRINT ~bigint%% (print in hexadecimal format) wasn't working as I expected - effectively truncating it to a 32 bit number.
When you know what the problem is, the manual makes it all clear:
" *HEX ... Control whether the hexadecimal conversion (& and ~) and bit-shift (<< and >>) operators treat their operands as 32-bit or 64-bit integers. In the (default) *HEX 32 mode the operators work in a fashion which is compatible with earlier versions of BBC BASIC; the operands are treated as 32-bit signed integers. In *HEX 64 mode the operands are treated as 64-bit signed integers. "