What is the size limit for numbers in LC? -- and multiplying really large numbers

Geoff Canyon gcanyon at gmail.com
Mon Sep 9 02:01:04 EDT 2013


Not sure whether to post this in this thread or the other, but in any case,
here is a routine that adds arbitrarily large positive numbers in any
LC-valid base -- 2 - 36. For the checksum problem, it would be fairly
simple to convert all the values to 64-bits and use this to add them,
either taking char -64 to -1 at the end, or along the way.

I haven't tested thoroughly:

function bigPlusBase X,Y,B
   -- returns X+Y in base B
   -- X and Y can be any length postitive integers in base B
   -- B is any valid LC base -- 2 through 36
   put "0000000" before X
   put "0000000" before Y
   put length(X) into LX
   put length(Y) into LY
   repeat
      add baseConvert(char LX - 5 to LX of X,B,10) + baseConvert(char LY -
5 to LY of Y,B,10) to S
      put baseConvert(S,10,B) into S
      put char -6 to -1 of ("0000000" & S) before R
      delete char -6 to -1 of S
      if S is not empty then put baseConvert(S,B,10) into S
      put max(6,LX - 6) into LX
      put max(6,LY - 6) into LY
      if LX = 6 and LY = 6 then exit repeat
   end repeat
   repeat with i = 1 to 8
      if char i of R is not "0" then return char i to -1 of R
   end repeat
end bigPlusBase



More information about the use-livecode mailing list