Jump to content

number fail help..i get 5.56e+031


Recommended Posts

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

Link to comment
Share on other sites

whatever Edited 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 ...
 

Link to comment
Share on other sites

  • Moderators

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 2

Looking 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. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 2

Looking 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. :mellow:

M23

try the BigNum UDF. It's amazing and surprisingly speedy.

Mat

Link to comment
Share on other sites

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 :mellow:

Link to comment
Share on other sites

  • Moderators

wipped,

try the BigNum UDF.

Good call from Mat - give it a try. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

whatever Edited 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 ...
 

Link to comment
Share on other sites

Hmm thanks for the reply but i dont really know how to use it can somebody help me?

Robin

All 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.

Link to comment
Share on other sites

:mellow: i read the inside but it are kinda big scripts, i think my collatz calculator will be pretty slow if i use it

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.

Link to comment
Share on other sites

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 :mellow: so i will try all the stuff tomorrow but now im gonna get some sleep...

cya

Link to comment
Share on other sites

I don't know what you're trying to do unfortunately or i'd help more... I might do some googling tonight :mellow:

lol i thougt it was like 12 pm but its only 10

do you have xfire or msn so i can add you then we can discus some.

Link to comment
Share on other sites

lol i thougt it was like 12 pm but its only 10

do 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 :mellow:

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

Link to comment
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to comment
Share on other sites

  • Moderators

jchd,

Oops! :mellow:

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! :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

0x4772616E74656421 :mellow:

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to comment
Share on other sites

jchd,

Oops! :mellow:

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! :P

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 :party:) 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 :party:

Edit: Woops, beaten to the post (literally) there, and I think I got some of conversions a bit wrong...

Edited by Mat
Link to comment
Share on other sites

whatever Edited 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 ...
 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...