tdpaxton Posted September 17, 2004 Posted September 17, 2004 Does anyone know a way to calculate big numbers in autoit? I was thinking of maybe using string variables and then using long division or something of that sort. Any suggestions?
Josbe Posted September 17, 2004 Posted September 17, 2004 For example? AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
tdpaxton Posted September 17, 2004 Author Posted September 17, 2004 For example? <{POST_SNAPBACK}>http://www.anujseth.com/crypto/bignumbers.html There's some ideas, I don't know much about programming
sugi Posted September 17, 2004 Posted September 17, 2004 First: This is no support forum as is mentioned at the top of every page here. For further questions please move to the support forum. Does anyone know a way to calculate big numbers in autoit? I was thinking of maybe using string variables and then using long division or something of that sort. Any suggestions?AutoIt can "only" process numbers up to the limits mentioned in the FAQ and the helpfile. If that's not enough for you, you can use the bc utility from http://unxutils.sourceforge.net/. bc is able to calculate with every number, no matter how big it is. But of course it needs some memory and time for very huge numbers. Just use strings instead of numbers to store the data in AutoIt and when you want to calculate you write something like:$bignumber1 = '327948658736837489265377' $bignumber2 = '475793367593747593748759362389454' FileWrite(@TempDir & '\bc.txt', $bignumber1 & ' + ' & $bignumber2 & @CRLF) RunWait(@ComSpec & ' /c bc <bc.txt >bcout.txt', @TempDir, @SW_HIDE) $Result = FileReadLine(@TempDir & '\bcout.txt') FileDelete(@TempDir & '\bc.txt') FileDelete(@TempDir & '\bcout.txt') MsgBox(0, 'Result', $Result)
jakub Posted December 2, 2007 Posted December 2, 2007 ive got the same problem and i didnt find the answere here so i write progs caunts n! to the result: a*10^b, where 1<a<10, and accuracy of a=0,0000000001 do +,-,/,* on numbers: a*10^b this was very important for me, maybe for someone else to some bugs may occurs, sugestions are welcome expandcollapse popup;for test: ;Msgbox(0,"",dzialania(silnia(InputBox("","Silnia"))&","&InputBox("","Dzialanie")&","&silnia(InputBox("","Silnia")))) func silnia($x) $y=1 $10=0 for $i=1 to $x $y*=$i while 1 if $y<10 then ExitLoop $y=Round($y/10,10) $10+=1 WEnd Next return ($y&"*10^"&$10) EndFunc func dzialania($dzialania);(2*10^2,+,3,1*10^3) $dzialania=StringSplit($dzialania,",") If UBound($dzialania)<4 then return 0 $liczba1=Stringsplit($dzialania[1],"*") $potega1=StringSplit($liczba1[2],"^") $potega1=Number($potega1[2]) If UBound($liczba1)<3 then return 0 $liczba2=StringSplit($dzialania[3],"*") $potega2=StringSplit($liczba2[2],"^") $potega2=Number($potega2[2]) If UBound($liczba2)<3 then return 0 Select Case $dzialania[2]="+" Select case $potega1=$potega2 $y=$liczba1[1]+$liczba2[1] $potega=$potega1 case $potega1>$potega2 while 1 $liczba1[1]=$liczba1[1]*10 $potega1-=1 if $potega1=$potega2 Then ExitLoop WEnd $y=$liczba1[1]+$liczba2[1] $potega=$potega1 Case $potega1<$potega2 while 1 $liczba2[1]=$liczba2[1]*10 $potega2-=1 if $potega1=$potega2 Then ExitLoop WEnd $y=$liczba1[1]+$liczba2[1] $potega=$potega1 EndSelect Case $dzialania[2]="-" Select case $potega1=$potega2 $y=$liczba1[1]-$liczba2[1] $potega=$potega1 case $potega1>$potega2 while 1 $liczba1[1]=$liczba1[1]*10 $potega1-=1 if $potega1=$potega2 Then ExitLoop WEnd $y=$liczba1[1]-$liczba2[1] $potega=$potega1 Case $potega1<$potega2 while 1 $liczba2[1]=$liczba2[1]*10 $potega2-=1 if $potega1=$potega2 Then ExitLoop WEnd $y=$liczba1[1]-$liczba2[1] $potega=$potega1 EndSelect Case $dzialania[2]="*" $y=$liczba1[1]*$liczba2[1] $potega=$potega1+$potega2 Case $dzialania[2]="/" $y=$liczba1[1]/$liczba2[1] $potega=$potega1-$potega2 EndSelect while 1 if $y<10 then ExitLoop $y=Round($y/10,10) $potega+=1 WEnd while 1 if $y>1 then ExitLoop $y=Round($y*10,10) $potega-=1 WEnd return ($y&"*10^"&$potega) EndFunc
Moderators SmOke_N Posted December 5, 2007 Moderators Posted December 5, 2007 For stepping outside the limitation of integers into uint etc... have a look here: http://www.autoitscript.com/forum/index.ph...st&p=431515 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now