wipped Posted June 15, 2010 Posted June 15, 2010 Hello I am making a script of collatz. But at some high numbers the number transforms in ...e+... how can i make sure that this wont happen or how can i transform it back to an normal number? Thanks anyways Robin Jan
MvGulik Posted June 15, 2010 Posted June 15, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
Moderators Melba23 Posted June 15, 2010 Moderators Posted June 15, 2010 wipped,The problem arises because AutoIt cannot deal with integers above 0x7FFFFFFF (2147483647). Anything above this is displayed in the exponential format which will not produce the degree of accuracy you require. Exponential notation works in powers of 10:100 = 1.0 e2 = 1 times 10 to the power 2Looking at the Collatz conjecture in my maths textbook:"Starting with 27 takes 111 steps to reach 1 with a maximum of 9232"So I can well believe that you could easily breach the Autoit limit with a not unreasonably sized seed number. And using exponential notation will not give you the level of accuracy you need to continue with the calculation.Sorry to be the bearer of bad tidings, but AutoIt is just not suited to this type of mathematical calculation - you need another language. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Mat Posted June 15, 2010 Posted June 15, 2010 wipped,The problem arises because AutoIt cannot deal with integers above 0x7FFFFFFF (2147483647). Anything above this is displayed in the exponential format which will not produce the degree of accuracy you require. Exponential notation works in powers of 10:100 = 1.0 e2 = 1 times 10 to the power 2Looking at the Collatz conjecture in my maths textbook:"Starting with 27 takes 111 steps to reach 1 with a maximum of 9232"So I can well believe that you could easily breach the Autoit limit with a not unreasonably sized seed number. And using exponential notation will not give you the level of accuracy you need to continue with the calculation.Sorry to be the bearer of bad tidings, but AutoIt is just not suited to this type of mathematical calculation - you need another language. M23try the BigNum UDF. It's amazing and surprisingly speedy.Mat AutoIt Project Listing
wipped Posted June 15, 2010 Author Posted June 15, 2010 tricky ... - The number your getting is just displayed in a way that makes sens for large numbers. use stringformat() to get it displayed in a other way. - I don't think you can do a collatz script with floats(or AutoIt double). - To get passed the normal in64 limitation your probably going to have to setup your own math functions. float_1() Func float_1() Local $n, $sOut For $i = 1 To 129 Step 32 $n = 2 ^ $i $sOut = String($i) & ') ' & String($n) & ', ' & StringFormat('%20.0f', $n) ConsoleWrite($sOut & @CRLF) Next EndFunc ;; output: ;~ 1) 2, 2 ;~ 33) 8589934592, 8589934592 ;~ 65) 3.68934881474191e+019, 36893488147419103000 ;~ 97) 1.58456325028529e+029, 158456325028528680000000000000 ;~ 129) 6.80564733841877e+038, 680564733841876930000000000000000000000 Looks pretty heavy... i will try making this function working Thanks for answering PS if anybody has an other solution just post it
Moderators Melba23 Posted June 15, 2010 Moderators Posted June 15, 2010 wipped,try the BigNum UDF.Good call from Mat - give it a try. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
wipped Posted June 15, 2010 Author Posted June 15, 2010 try the BigNum UDF. It's amazing and surprisingly speedy.MatHmm thanks for the reply but i dont really know how to use it can somebody help me?Robin
wipped Posted June 15, 2010 Author Posted June 15, 2010 i read the inside but it are kinda big scripts, i think my collatz calculator will be pretty slow if i use it
MvGulik Posted June 15, 2010 Posted June 15, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
Mat Posted June 15, 2010 Posted June 15, 2010 Hmm thanks for the reply but i dont really know how to use it can somebody help me?RobinAll the numbers are stored as strings, so there is no limit to their size other than the windows string size and the memory (I haven't tried though). The only problem is that you have to call functions _BigNum_* rather than use the in-built operators. I haven't used it for a while but I believe there are all the functions you'll need there. Jennico wrote some very rapid root functions if you read further down the thread. AutoIt Project Listing
Mat Posted June 15, 2010 Posted June 15, 2010 i read the inside but it are kinda big scripts, i think my collatz calculator will be pretty slow if i use itIt's big, but its fast. I tried making my own using arrays etc but it couldn't scratch it for performance.If you want speed you're using the wrong language. If you still want to use AutoIt you might want to try making a c++ dll with an AutoIt wrapper. AutoIt Project Listing
wipped Posted June 15, 2010 Author Posted June 15, 2010 It's big, but its fast. I tried making my own using arrays etc but it couldn't scratch it for performance.If you want speed you're using the wrong language. If you still want to use AutoIt you might want to try making a c++ dll with an AutoIt wrapper.im just using it for fun so i will try all the stuff tomorrow but now im gonna get some sleep...cya
Mat Posted June 15, 2010 Posted June 15, 2010 im just using it for fun so i will try all the stuff tomorrow but now im gonna get some sleep...cyaI don't know what you're trying to do unfortunately or i'd help more... I might do some googling tonight AutoIt Project Listing
wipped Posted June 15, 2010 Author Posted June 15, 2010 I don't know what you're trying to do unfortunately or i'd help more... I might do some googling tonight lol i thougt it was like 12 pm but its only 10do you have xfire or msn so i can add you then we can discus some.
Mat Posted June 15, 2010 Posted June 15, 2010 lol i thougt it was like 12 pm but its only 10do you have xfire or msn so i can add you then we can discus some.Nope... at least I don't think so...It is my bed time though, so I'm off. If you want then pm me. I've read wikipedia and it sounds like a simple enough program, a bit like projecteuler.net would give you, so I don't mind helping out If not I'll pm you if I get anything done, I'm done with tests on friday so I'll have plenty of time.Mat AutoIt Project Listing
jchd Posted June 16, 2010 Posted June 16, 2010 The problem arises because AutoIt cannot deal with integers above 0x7FFFFFFF (2147483647). Anything above this is displayed in the exponential format which will not produce the degree of accuracy you require.I beg to differ. AutoIt will switch from signed 32-bit to signed 64-bit integers when needed for arithmetical operations. Several operations of functions still can't cope with those 64-bit ints, notably bitwise functions, Hex(), ... Local $n = 0x7fffffff For $i = 1 to 1234567890 Step 54321 ConsoleWrite($n & @LF) $n += $i Next This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Moderators Melba23 Posted June 16, 2010 Moderators Posted June 16, 2010 jchd,Oops! Read the wrong line in the Help file:Number range (integers): 64-bit signed integerHexadecimal numbers: 32-bit signed integer (0x80000000 to 0x7FFFFFFF)So I claim half a point because I did specify the limit in Hex! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jchd Posted June 16, 2010 Posted June 16, 2010 0x4772616E74656421 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Mat Posted June 16, 2010 Posted June 16, 2010 (edited) jchd, Oops! Read the wrong line in the Help file: Number range (integers): 64-bit signed integer Hexadecimal numbers: 32-bit signed integer (0x80000000 to 0x7FFFFFFF) So I claim half a point because I did specify the limit in Hex! M23 Ermm... Where did you see that? Only I did a bit of testing using this: $n = 2 ^ 48 $i = 2 ^ 49 While 1 While Not StringInStr(String($i + $n), "e") $i += $n ToolTip($i) WEnd If $n = 1 Then ExitLoop $n /= 2 WEnd ToolTip("") ClipPut($i) ; 999999999999999 And got 999999999999999 which is 0x38D7EA4C67FFF in hex and 11100011010111111010100100110001100111111111111111 in binary and as you would have guessed not a normal computer max, more a human one. That number itself is somewhere between 2^49 and 2^50. So. You're both (nope... reading it again gets just Melba i'm afraid ) wrong, reading helpfile entries that are slightly outdated - talking about converting from v2 and most noticeably the line length limit (now removed as of 3.3.4.0). I win Edit: Woops, beaten to the post (literally) there, and I think I got some of conversions a bit wrong... Edited June 16, 2010 by Mat AutoIt Project Listing
MvGulik Posted June 16, 2010 Posted June 16, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
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