J JPU Senior Member Aug 27, 2014 #1 Please can someone tell me if there is a simple way to reverse BINTOASCII, here is the code b0=123 bintoascii b0, b4,b5,b6 my solution would be: b4=b4*100 b5=b5*10 b0=b4+b5+b6 Is this the way or is there a correct way? Thanks
Please can someone tell me if there is a simple way to reverse BINTOASCII, here is the code b0=123 bintoascii b0, b4,b5,b6 my solution would be: b4=b4*100 b5=b5*10 b0=b4+b5+b6 Is this the way or is there a correct way? Thanks
B BeanieBots Moderator Aug 27, 2014 #3 srnet said: How about; b0 = b4 * 10 + b5 * 10 + b6 Click to expand... Almost but not quite. The returned values are in ASCII so, if b0 = "0" then b0 - "0" = 0 (ie, you also need to convert from ASCII to BIN) Try:- b0 =b4 - "0" * 10 + b5 - "0" * 10 + b6 - "0"
srnet said: How about; b0 = b4 * 10 + b5 * 10 + b6 Click to expand... Almost but not quite. The returned values are in ASCII so, if b0 = "0" then b0 - "0" = 0 (ie, you also need to convert from ASCII to BIN) Try:- b0 =b4 - "0" * 10 + b5 - "0" * 10 + b6 - "0"
hippy Technical Support Staff member Aug 27, 2014 #4 BeanieBots said: b0 =b4 - "0" * 10 + b5 - "0" * 10 + b6 - "0" Click to expand... And optimised, because 1008 = ( "0" * 100) + ( "0" * 10 ) + "0" ... b0 = b4 * 10 + b5 * 10 + b6 - 1008
BeanieBots said: b0 =b4 - "0" * 10 + b5 - "0" * 10 + b6 - "0" Click to expand... And optimised, because 1008 = ( "0" * 100) + ( "0" * 10 ) + "0" ... b0 = b4 * 10 + b5 * 10 + b6 - 1008
J JPU Senior Member Aug 27, 2014 #5 Thanks for that, I thought there might have been a command? I guess not.