Krsta Posted April 5, 2021 Share Posted April 5, 2021 (edited) I found some inconsistencies in storing/using numbers in variables end in expressions.Here is the test script: Global $var For $i = 0 To 1024 Step 2 ;~ Local $var = Number(3 + 2 ^ $i) $var = Number(3 + 2 ^ $i) ConsoleWrite($i & "/VarGetType(" & VarGetType($var) & ")/Binary(" & Binary($var) & ")/IsFloat(" & IsFloat($var) & ")/String(" & String($var) & ")") ConsoleWrite(@CRLF) Next It can be seen in the output that for $i = 50, VarGetType is (Double) and IsFloat (0).In addition, INT64 is enough for 2 ^ 50 + 3, but this is the double actually.Similarly for $i = 0 (3 + 2 ^ 0 = 4).It can also be seen from the output of the Binary function,that the internal type of $var is INT64 for $i = 1 to 48 and Double otherwise.Therefore, I conclude that the result of the VarGetType function is OK.The IsFloat function is incorrect for $ i = 50 to 62 and also for 0.I understand that the expression produces a double instead of an INT64 even where it is not needed.Changing the variable from Global to Local does not change anything. I don't know if these are AutoItScript errors or mine. My environment: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "R:\P\sort\testPoradi.au3" /UserParams +>16:50:38 Starting AutoIt3Wrapper (19.1127.1402.26) from:SciTE.exe (4.2.0.0) Keyboard:00010405 OS:WIN_10/1909 CPU:X64 OS:X64 Environment(Language:0405) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\du\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\du\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:R:\P\sort\testPoradi.au3 +>16:50:39 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\P\sort\testPoradi.au3" Edited April 5, 2021 by Krsta Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2021 Share Posted April 5, 2021 There is no error, strictly speaking. A double stores a value, integral or not, which is what IsFloat tells you. IsFloat() doesn't tell you about the variable datatype, just that it holds an integral value or not. And yes, the returned datatype for $i = 0 is an anomaly, which isn't an error since the result is mathematically correct. Now why the datatype change around 2^50 is a mystery as well, but still not a bug (the result is always correct). My version: Global $var For $i = 0 To 1024 $var = 3 + 2 ^ $i ConsoleWrite($i & @TAB & VarGetType($var) & @TAB & Binary($var) & @TAB & (IsFloat($var) ? "Fractional" : "Integral") & @TAB & '"' & String($var) & '"' & @LF) If $i = 4 Then $i = 45 ConsoleWrite("..." & @LF) EndIf If $i = 51 Then $i = 59 ConsoleWrite("..." & @LF) EndIf If $i = 65 Then $i = 1020 ConsoleWrite("..." & @LF) EndIf 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) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2021 Moderators Share Posted April 5, 2021 jchd, Quote why the datatype change around 2^50 is a mystery I imagine it is because the value of 2 ^ $i becomes too big to store in an Int64 and so needs a Double - see this extract from the output of my slightly amended script: 48/VarGetType(Int64)/Binary(0x0300000000000100)/IsFloat(0)/String(281474976710659) 2^48 = 281474976710656 50/VarGetType(Double)/Binary(0x0C00000000001043)/IsFloat(0)/String(1.12589990684263e+15) 2^50 = 1.12589990684262e+15 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 Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2021 Share Posted April 5, 2021 3 minutes ago, Melba23 said: I imagine it is because the value of 2 ^ $i becomes too big to store in an Int64 and so needs a Double No, because an int64 can store up to 2^63-1. Local $n = 33554432 ; that is 2^25 Local $p = $n * $n ; 2^50 ConsoleWrite($p & @TAB & VarGetType($p) & @LF) $n = 1073741824 ; that is 2^30 Local $p = $n * $n ; 2^60 ConsoleWrite($p & @TAB & VarGetType($p) & @LF) 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) Link to comment Share on other sites More sharing options...
Nine Posted April 5, 2021 Share Posted April 5, 2021 (edited) @jchd You mean Uint64 as int64 is signed. But in any case there is still that "bug" : #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> For $i = 46 to 50 $num = 2^$i ConsoleWrite ($i & " = " & Hex($num) & @CRLF) Next where it breaks at 49. Edited April 5, 2021 by Nine nvm misread your post “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2021 Share Posted April 5, 2021 No I really meant 2^63-1 for an INT64. Count up to 2^64-1 for an UINT64 (which AutoIt doesn't have). 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) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2021 Moderators Share Posted April 5, 2021 jchd, Well, something happens when we reach 2^50 as can be seen by change to expressing the value in scientific notation - perhaps an internal AutoIt limit? 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 Link to comment Share on other sites More sharing options...
AspirinJunkie Posted April 5, 2021 Share Posted April 5, 2021 (edited) One approach: Let's assume that internally the calculation is always done with float/double, no matter if the operands are integers or not. Many libraries do not offer an integer power function. Only at the end the result is cast to integer. However, crazy casting problems occur, which show up only from 2^49: ConsoleWrite(StringFormat("%19s : %s (%s)\n", "2 ^ 49", 2^49, VarGetType(2^49))) ConsoleWrite(StringFormat("%19s : %s (%s)\n", "2.0 ^ 49", 2.0^49, VarGetType(2.0^49))) ConsoleWrite(StringFormat("%19s : %s (%s)\n", "Int(2.0 ^ 49)", Int(2.0^49), VarGetType(Int(2.0^49)))) ConsoleWrite(StringFormat("%19s : %s (%s)\n", "Number(2.0 ^ 49, 2)", Number(2.0^49, 2), VarGetType(Number(2.0^49, 2)))) ;problem in short: ConsoleWrite(Int(562949953421312) & @CRLF & Int(562949953421312.0) & @CRLF) Therefore one has probably drawn in this hard limit for the casting in integer so that these "rounding errors" cannot occur. However, it is an absolute mystery to me how this comes about, since 2^49 can be represented exactly in IEEE 754 Double. So there should be no binary rounding problem or something equivalent in question. If you really want to use an integer power, you can of course also use AutoIt: For $i = 46 to 50 $num = 2^Int($i) ConsoleWrite($i & @TAB & $num & @TAB & VarGetType($num) & @CRLF) Next ConsoleWrite("---------------------" & @CRLF) For $i = 46 to 50 $num = pow(2, $i) ConsoleWrite($i & @TAB & $num & @TAB & VarGetType($num) & @CRLF) Next Func pow($iE, $iP) If $iP = 0 Then Return 1 If $iP = 1 Then Return $iE Local $iT = pow($iE, BitShift($iP, 1)) If Mod($iP, 2) = 0 Then Return $iT * $iT Return $iE * $iT * $iT EndFunc Edited April 5, 2021 by AspirinJunkie Link to comment Share on other sites More sharing options...
Krsta Posted April 5, 2021 Author Share Posted April 5, 2021 It's more mystery of the number 49 not 50. If we change script slightly (Step 1): Global $var For $i = 0 To 102 Step 1 ;~ Local $var = Number(3 + 2 ^ $i) $var = Number(3 + 2 ^ $i) ConsoleWrite($i & "/VarGetType(" & VarGetType($var) & ")/Binary(" & Binary($var) & ")/IsFloat(" & IsFloat($var) & ")/String(" & String($var) & ")") ConsoleWrite(@CRLF) Next we can see, that change from INT64 to Double is for $i = 49. But it is still mystery... Link to comment Share on other sites More sharing options...
Krsta Posted April 5, 2021 Author Share Posted April 5, 2021 There is a version without "^": Global $var, $prod = 1 For $i = 1 To 102 Step 1 $prod = $prod * 2 $var = Number(3 + $prod) ConsoleWrite($i & "/VarGetType(" & VarGetType($var) & ")/Binary(" & Binary($var) & ")/IsFloat(" & IsFloat($var) & ")/String(" & String($var) & ")") ConsoleWrite(@CRLF) Next No 49 mystery. But for $i = 63 there is another problem. $var should be Double, but instead is negative INT64. And more: $var = 3 for $i > 63 Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2021 Share Posted April 5, 2021 (edited) 17 minutes ago, Krsta said: But for $i = 63 there is another problem. $var should be Double, but instead is negative INT64. And more: $var = 3 for $i > 63 That is integer overflow because you operate on integers. Very few languages have guards against that. It doesn't occur with ^ since (I believe) the operation in this case is first done with the FP unit before being cast to Int. You can get a similar integer overflow with addition: Local $n = 9223372036854775807 ; max positive int64 ConsoleWrite($n & @TAB & VarGetType($n) & @LF) $n += 1 ConsoleWrite($n & @TAB & VarGetType($n) & @LF) As usual: know the data you operate on. Edited April 5, 2021 by jchd 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) Link to comment Share on other sites More sharing options...
markyrocks Posted April 6, 2021 Share Posted April 6, 2021 ;just for fun ConsoleWrite(_pow(2,49)&@CRLF) ConsoleWrite(_pow(2,50)&@CRLF) ConsoleWrite(_pow(2,62)&@CRLF) ConsoleWrite(_pow(2.0,63));<~~cuts off the end of the number Func _pow($a,$b) if $a=0 or $b<0 then return 0 if $b=0 or $a=1 then return 1 if $a<0 then $a= -$a Local $result=$a While $b>1 $result*=$a $b-=1 WEnd Return $result EndFunc I was kinda interested in this so I been playing around with it for a bit. I knew when I started that the pow function in c++ takes doubles as params and returns a double. That and the difference between 2^49 = 15 digits and 2^50=16 digits. Apparently a double can only be 15 digits long so once the return value of the pow is greater than 15 digits then some precision is lost. As you can see from the picture 2^50 = 1,125,899,906,842,624 the return value of pow(2,50) = 1.12589990684262e+15. The 4 gets cut off and I'm assuming that nothing can be done about that unless you write a custom function. Then you can see when I cast to an int it rounds up to 1,125......625 for some reason. IDK just my 2 cents. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
AspirinJunkie Posted April 6, 2021 Share Posted April 6, 2021 53 minutes ago, markyrocks said: Apparently a double can only be 15 digits long so once the return value of the pow is greater than 15 digits then some precision is lost. As you can see from the picture 2^50 = 1,125,899,906,842,624 the return value of pow(2,50) = 1.12589990684262e+15. The 4 gets cut off and I'm assuming that nothing can be done about that unless you write a custom function. This is only due to the implicit string conversion because of the presentation in the messagebox. You can force to print the number completely instead of the scientific notation with StringFormat: $i = 2.0^50 MsgBox(0,"", StringFormat("%30f", $i)) 58 minutes ago, markyrocks said: Then you can see when I cast to an int it rounds up to 1,125......625 for some reason. That's the whole point. As I wrote above, this problem does not affect 2^50 but already 2^49 where 562,949,953,421,312.0 is cast to 562,949,953,421,313 So the real problem is the conversion to integer and probably that's why they refrained from casting to integer above 2^48. The question is where exactly is the problem with the internal type conversion as it is obviously also used in Int(). The problematic numbers can all be mapped completely and without rounding errors in IEEE754 double precision. Therefore, no problems with the conversion are actually to be expected. C/C++ (where AutoIt was written) does not show the same behavior: #include <iostream> using namespace std; int main() { double f = 562949953421312.0; long long iInt1 = (long long)f; long long iInt2 = static_cast<long long>(f); cout<<iInt1<<"\n"<<iInt2; } Link to comment Share on other sites More sharing options...
jchd Posted April 6, 2021 Share Posted April 6, 2021 (edited) After closer look, the behavior is correct. The double format has 52 bit of mantissa (while I wrongly seemed to recall it has a few more). The bit sign is separate, hence the mantissa represents the absolute value (after scaling). Since zero has a separate (fractional) representation the 52 bit of mantissa can represent one more than 52 bits of integral types. As a consequence integral values in [-(2^53), 2^53] can be stored exactly as integers in the mantissa. Any integral value outside that interval will be stored as fractional. EDIT: except integral powers of 2 in [2^54, 2^1023], where the mantissa is exactly 1. Here's a breakout of values around the limit. You can see that 9007199254740993 can't be represented exactly. ULPs(0) ULPs(2^53-1) ULPs(2^53) ULPs(2^53+1) Result: expandcollapse popupInput value = 0 FP (binary) = 0x0000000000000000 Sign = + Exponent = -1023 Scaling = 2^-1023 = 1/89884656743115795386465259539451236680898848947115328636715040578866337902750481566354238661203768010560056939935696678829394884407208311246423715319737062188883946712432742638151109800623047059726541476042502884419075341171231440736956555270413618581675255342293149119973622969239858152417678164812112068608 Mantissa = 1 Nearby exact values (computed from FP bits) PrePrevious = +0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Previous = +0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Value = +0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Next = +0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 NextNext = +0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ================================== Input value = 9.00719925474099e+15 FP (binary) = 0x433FFFFFFFFFFFFF Sign = + Exponent = 52 Scaling = 2^52 = 4503599627370496 Mantissa = 1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64 + 1/128 + 1/256 + 1/512 + 1/1024 + 1/2048 + 1/4096 + 1/8192 + 1/16384 + 1/32768 + 1/65536 + 1/131072 + 1/262144 + 1/524288 + 1/1048576 + 1/2097152 + 1/4194304 + 1/8388608 + 1/16777216 + 1/33554432 + 1/67108864 + 1/134217728 + 1/268435456 + 1/536870912 + 1/1073741824 + 1/2147483648 + 1/4294967296 + 1/8589934592 + 1/17179869184 + 1/34359738368 + 1/68719476736 + 1/137438953472 + 1/274877906944 + 1/549755813888 + 1/1099511627776 + 1/2199023255552 + 1/4398046511104 + 1/8796093022208 + 1/17592186044416 + 1/35184372088832 + 1/70368744177664 + 1/140737488355328 + 1/281474976710656 + 1/562949953421312 + 1/1125899906842624 + 1/2251799813685248 + 1/4503599627370496 Nearby exact values (computed from FP bits) PrePrevious = +9007199254740989 Previous = +9007199254740990 Value = +9007199254740991 Next = +9007199254740992 NextNext = +9007199254740994 ================================== Input value = 9.00719925474099e+15 FP (binary) = 0x4340000000000000 Sign = + Exponent = 53 Scaling = 2^53 = 9007199254740992 Mantissa = 1 Nearby exact values (computed from FP bits) PrePrevious = +9007199254740990 Previous = +9007199254740991 Value = +9007199254740992 Next = +9007199254740994 NextNext = +9007199254740996 ================================== Input value = 9.00719925474099e+15 FP (binary) = 0x4340000000000000 Sign = + Exponent = 53 Scaling = 2^53 = 9007199254740992 Mantissa = 1 Nearby exact values (computed from FP bits) PrePrevious = +9007199254740990 Previous = +9007199254740991 Value = +9007199254740992 Next = +9007199254740994 NextNext = +9007199254740996 Edited April 6, 2021 by jchd 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) Link to comment Share on other sites More sharing options...
AspirinJunkie Posted April 6, 2021 Share Posted April 6, 2021 6 minutes ago, jchd said: After closer look, the behavior is correct. [...] As a consequence integral values in [-(2^53), 2^53] can be stored exactly as integers in the mantissa. The behavior occurs already at 2^49 and not only at 2^53. Also the conversion problem of Int(). Link to comment Share on other sites More sharing options...
jchd Posted April 6, 2021 Share Posted April 6, 2021 Ha yes, that. You're correct that the conversion from FP to Int64 goes wrong above 2^48, didn't notice that before. And it actually is a bug. Local $n For $i = 47 To 54 $n = 2^$i ConsoleWrite($i & @TAB & StringFormat("%20s", Int($n)) & @TAB & StringFormat("%20.1f", $n) & @TAB & (IsFloat($n) ? "Fractional" : "Integral") & @TAB & VarGetType($n) & @LF) Next Shows that Int(2^49) and beyond yields an odd result, trivially wrong. 47 140737488355328 140737488355328.0 Integral Int64 48 281474976710656 281474976710656.0 Integral Int64 49 562949953421313 562949953421312.0 Integral Double 50 1125899906842625 1125899906842624.0 Integral Double 51 2251799813685249 2251799813685248.0 Integral Double 52 4503599627370497 4503599627370496.0 Integral Double 53 9007199254740993 9007199254740992.0 Integral Double 54 18014398509481985 18014398509481984.0 Integral Double 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) Link to comment Share on other sites More sharing options...
AspirinJunkie Posted April 6, 2021 Share Posted April 6, 2021 Your explanations let the feeling mature in me that internally possibly with 48 bits mantissa is calculated. But we can't resolve that any further from our point of view. 4 minutes ago, jchd said: And it actually is a bug. Already reported: >>Ticket 3817<< Link to comment Share on other sites More sharing options...
jchd Posted April 6, 2021 Share Posted April 6, 2021 Thanks for the ticket. My advice when one has clues that values can get unusually large: use the BigNum UDF. It isn't a full-fledged arbitrary precision library but reveals much more stable in most use cases than FP when at least one value gets quite large, e.g. 3^157 + 43 or when you really have to deal with many decimals. 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) Link to comment Share on other sites More sharing options...
markyrocks Posted April 6, 2021 Share Posted April 6, 2021 12 hours ago, AspirinJunkie said: This is only due to the implicit string conversion because of the presentation in the messagebox. Good to know. For some reason I thought that some data had been lost after a double became so big due to some memory limitation or etc. I did find it odd that the int cast rounded to 5 so I had a feeling the data was there bc it would have been a zero otherwise but just kinda fell through the cracks in my thought process. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
JockoDundee Posted April 8, 2021 Share Posted April 8, 2021 On 4/6/2021 at 2:43 AM, AspirinJunkie said: Already reported: >>Ticket 3817<< Already reported: >>Ticket 3703<< Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
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