![]() |
Forum Index : Microcontroller and PC projects : CMM2: Signed vs. unsigned right-shift
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi folks, I seem to recall we got a new >>> operator at some point during the 5.07 firmware betas but it isn't covered by the manual or the inbuilt MMBasic help yet. Can anyone point me back at the original post about it as my google-fu has failed me. Related to this I think the signed and unsigned operators are the opposite way around to BBC Basic, that should make for some fun bugs if anyone does some porting. Alas even if that is true there isn't anything obvious that can be done without breaking old MMBasic programs ![]() Best wishes, Tom Edited 2021-05-16 09:10 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
'ere 'tis new operator for signed shift right integervariable>>n' for unsigned shift right integervariable>>>n' for signed shift right Link Bill Keep safe. Live long and prosper. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
The CMM2 manual has the description of >> incorrect The micromite manual is correct. DIM INTEGER x, y, z, w x = 12345 y = x << 8 z = x >> 8 w = x >>> 8 ' not all versions have this operator PRINT "x = ";BIN$(x,64);" ";x PRINT "x << 8= ";BIN$(y,64);" ";y PRINT "x = ";BIN$(x,64);" ";x PRINT "x >> 8= ";BIN$(z,64);" ";z PRINT "x >>>8= ";BIN$(w,64);" ";w x = &h7FFFFFFFFFFF7F y = x << 8 z = x >> 8 w = x >>> 8 PRINT "x = ";BIN$(x,64);" ";x PRINT "x << 8= ";BIN$(y,64);" ";y y = x << 9 PRINT "x << 9= ";BIN$(y,64);" ";y PRINT "x = ";BIN$(x,64);" ";x PRINT "x >> 8= ";BIN$(z,64);" ";z PRINT "x >>>8= ";BIN$(w,64);" ";w x = 0-&h7FFFFFFFFFFF7F y = x << 8 z = x >> 8 w = x >>> 8 PRINT "x = ";BIN$(x,64);" ";x PRINT "x << 8= ";BIN$(y,64);" ";y y = x << 9 PRINT "x << 9= ";BIN$(y,64);" ";y PRINT "x = ";BIN$(x,64);" ";x PRINT "x >> 8= ";BIN$(z,64);" ";z PRINT "x >>>8= ";BIN$(w,64);" ";w 'Output: ' 'x = 0000000000000000000000000000000000000000000000000011000000111001 12345 'x << 8= 0000000000000000000000000000000000000000001100000011100100000000 3160320 ' 'x = 0000000000000000000000000000000000000000000000000011000000111001 12345 'x >> 8= 0000000000000000000000000000000000000000000000000000000000110000 48 'x >>>8= 0000000000000000000000000000000000000000000000000000000000110000 48 ' 'x = 0000000001111111111111111111111111111111111111111111111101111111 36028797018963839 'x << 8= 0111111111111111111111111111111111111111111111110111111100000000 9223372036854742784 'x << 9= 1111111111111111111111111111111111111111111111101111111000000000 -66048 ' 'x = 0000000001111111111111111111111111111111111111111111111101111111 36028797018963839 'x >> 8= 0000000000000000011111111111111111111111111111111111111111111111 140737488355327 'x >>>8= 0000000000000000011111111111111111111111111111111111111111111111 140737488355327 ' 'x = 1111111110000000000000000000000000000000000000000000000010000001 -36028797018963839 'x << 8= 1000000000000000000000000000000000000000000000001000000100000000 -9223372036854742784 'x << 9= 0000000000000000000000000000000000000000000000010000001000000000 66048 ' 'x = 1111111110000000000000000000000000000000000000000000000010000001 -36028797018963839 'x >> 8= 0000000011111111100000000000000000000000000000000000000000000000 71916856549572608 'x >>>8= 1111111111111111100000000000000000000000000000000000000000000000 -140737488355328 ' Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |