Integer-Calculation with 24 decimals?

dunbarx at aol.com dunbarx at aol.com
Tue Nov 13 13:55:07 EST 2012


Hi.


I made a gadget in HC long (and I mean long) ago that did this for addition. Here is the code:




function longAdd arg1,arg2
   put 0 into carry
   put abs(the length of arg1-the length of arg2) into numzeros
   repeat numzeros
      put "0" after leadingZeros
   end repeat
   
   if the length of arg1 >= the length of arg2 then
      put the length of arg1 into index
      put leadingZeros before arg2
   else
      put the length of arg2 into index
      put leadingZeros before arg1
   end if
   repeat with y = index down to 1
      put char y of arg1 + char y of arg2 + carry into temp
      if char y of arg1 + char y of arg2 + carry > 9 then put 1 into carry else put 0 into carry
      put last char of temp before accum
   end repeat
   if carry = 1 then put "1" before accum
   return accum
end longAdd




Craig Newman



-----Original Message-----
From: R. Hillen <mail at richard-hillen.de>
To: use-livecode <use-livecode at lists.runrev.com>
Sent: Tue, Nov 13, 2012 10:42 am
Subject: Integer-Calculation with 24 decimals?


Hello list,

I have to do a lot of calculations like 1234516789012345678901234 mod 97;  
(always 24 decimals)

IntegerCalculation in LC with 24 decimals doesn´t work valide.

Does anyone of you know of an external function or a mathematical trick or … 

Thank you in advance!

Richard.
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list