timsky Posted March 11, 2019 Share Posted March 11, 2019 (edited) $iInt64 = Int(2 ^ 62, 2) ConsoleWrite($iInt64 & @lf) = 4611686018427387905 Bug starts at 2 ^ 49 and further. 2 ^ 63 gives -9223372036854775808 as result. Why negative? AutoIt 3.3.14.5. PS: I also found other math bug(s) in more complex code but can not determine where. Maybe it is related. Edited March 11, 2019 by timsky Link to comment Share on other sites More sharing options...
Nine Posted March 11, 2019 Share Posted March 11, 2019 16 minutes ago, timsky said: 2 ^ 63 gives -9223372036854775808 as result. Why negative? Leftmost bit = 1 thus negative ? But you got definitively a bug here. You should report it in bug tracker. Try : MsgBox ($MB_SYSTEMMODAL,"",Hex (2^48)) MsgBox ($MB_SYSTEMMODAL,"",Hex (2^49)) Obvious. “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...
BrewManNH Posted March 11, 2019 Share Posted March 11, 2019 From the help file for Int() Quote This function makes minor corrections to floating point numbers to account for the imprecise nature of floating point numbers. For example, the floating point expression 0.7 + 0.2 + 0.1 produces a floating point number that is not quite 1.0. Int() corrects for this anomaly, however, certain extremely rare circumstances may lead to Int() returning an unexpected value (the odds of getting an unexpected value are less than if Int() did not attempt any correction at all). If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Bilgus Posted March 11, 2019 Share Posted March 11, 2019 How about an iPow function? ConsoleWrite(iPow(2, 49) & @CRLF) ConsoleWrite(iPow(2, 50) & @CRLF) ConsoleWrite(iPow(2, 62) & @CRLF) ConsoleWrite(iPow(2, 63) & @CRLF) Func iPow($iBase, $iExp, $sType = "UINT64") $tRes = DllStructCreate($sType) DllStructSetData($tRes, 1, 1) While $iExp > 0 If BitAND($iExp, 1) = 1 Then DllStructSetData($tRes, 1, DllStructGetData($tRes, 1) * $iBase) EndIf $iExp = BitShift($iExp, 1) ;Right shift 1 $iBase *= $iBase WEnd Return DllStructGetData($tRes, 1) EndFunc ;==>iPow 562949953421312 1125899906842624 4611686018427387904 -9223372036854775808 note the 2 ^ 63 still outputs a negative number but that is a limitation of Autoit not the algorithm and further processing would be needed Link to comment Share on other sites More sharing options...
Bilgus Posted March 11, 2019 Share Posted March 11, 2019 Even better.. czardas 1 Link to comment Share on other sites More sharing options...
BrewManNH Posted March 11, 2019 Share Posted March 11, 2019 17 minutes ago, Bilgus said: but that is a limitation of Autoit That is a limitation of working with floating point numbers in any system. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Bilgus Posted March 11, 2019 Share Posted March 11, 2019 Well yes but I'm saying since the underlying datatype in autoit is signed even though the number is UINT64 it is displayed as INT64 Link to comment Share on other sites More sharing options...
timsky Posted March 11, 2019 Author Share Posted March 11, 2019 Bilgus, thanks for iPow and operator64 Ticket is there: https://www.autoitscript.com/trac/autoit/ticket/3703 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