Jump to content

Number Puzzle


czardas
 Share

Recommended Posts

The value changed.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Only the last digit is changed

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

This is the drawback of 2's complement representation: the range isn't symetric around zero. So -(-128 ) isn't representable as a signed byte, up to whatever fixed integral size your hardware/software handles.

1's complement doesn't have the issue, but then you end up with another problem: you get distinct values for +0 and -0.

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

why do the top two work?

ConsoleWrite(int("-9223372036854775808" , 2) & @LF)
ConsoleWrite(number("-9223372036854775808" , 2) & @LF)
ConsoleWrite(-9223372036854775808 & @LF)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

even this will change:

ConsoleWrite(9223372036854775808 & @LF)

the reason is that:

Maximum value for a number of type int64 is  9223372036854775807 --> 0111111111111111111111111111111111111111111111111111111111111111

Minimum value for a number of type int64 is -9223372036854775807 --> 1000000000000000000000000000000000000000000000000000000000000001

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I honestly don't remember which machine/processor used 1's complement and used all zeroes to denote +/- zero but the value normally assigned to -0 was used to denote overflow. That was much easier to deal with and I believe it's only for historical inheritance that we have to cope with asymetry in integral representations. It's a pity for it would be much easier to work with that, now that gate count is essentially irrelevant. Geez, compatibility, what hard ways you force us to walk thru.

Minimum value for a number of type int64 is -9223372036854775807 --> 1000000000000000000000000000000000000000000000000000000000000001

Wrong: substract 1 to that.

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

Minimum value for a number of type int64 is -9223372036854775807 --> 1000000000000000000000000000000000000000000000000000000000000001

 

but int and number can reach -9223372036854775808

ConsoleWrite(int("-9223372036854775810" , 2) & @LF)
ConsoleWrite(number("-9223372036854775810" , 2) & @LF)
ConsoleWrite(-9223372036854775810 & @LF)

ConsoleWrite(int("-9223372036854775809" , 2) & @LF)
ConsoleWrite(number("-9223372036854775809" , 2) & @LF)
ConsoleWrite(-9223372036854775809 & @LF)

ConsoleWrite(int("-9223372036854775808" , 2) & @LF)
ConsoleWrite(number("-9223372036854775808" , 2) & @LF)
ConsoleWrite(-9223372036854775808 & @LF)

 

 

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

evidently int () and number () can handle even the value -9223372036854775808 ->
1000000000000000000000000000000000000000000000000000000000000000

while ConsoleWrite don't accept this value limit ....

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

try this:
each value greater then 9223372036854775807 is truncated to 9223372036854775807 by ConsoleWrite
each value lower than -9223372036854775807 is truncated to -9223372036854775807 by ConsoleWrite

ConsoleWrite(9223372036854775809999999 & @LF)
ConsoleWrite(92233720368547758099999 & @LF)
ConsoleWrite(922337203685477580999 & @LF)
ConsoleWrite(92233720368547758099 & @LF)
ConsoleWrite(9223372036854775809 & @LF)
ConsoleWrite(9223372036854775808 & @LF)
ConsoleWrite(9223372036854775807 & @LF) ; <--- upper limit
ConsoleWrite(9223372036854775806 & @LF)
ConsoleWrite(-9223372036854775806 & @LF)
ConsoleWrite(-9223372036854775807 & @LF) ; <--- lower limit
ConsoleWrite(-9223372036854775808 & @LF)
ConsoleWrite(-9223372036854775809 & @LF)
ConsoleWrite(-92233720368547758099 & @LF)
ConsoleWrite(-922337203685477580999 & @LF)
ConsoleWrite(-92233720368547758099999 & @LF)
ConsoleWrite(-9223372036854775809999999 & @LF)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Yep:

Local $n = 0x8000000000000000
ConsoleWrite($n & @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 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

Wrong: substract 1 to that.

yes.... weirdness....

ConsoleWrite(-9223372036854775807     & @LF) ; -9223372036854775807   1000000000000000000000000000000000000000000000000000000000000001
ConsoleWrite(-9223372036854775807 - 1 & @LF) ; -9223372036854775808   1000000000000000000000000000000000000000000000000000000000000000  <-- OK
ConsoleWrite(-9223372036854775807 - 2 & @LF) ;  9223372036854775807   0111111111111111111111111111111111111111111111111111111111111111  <-- wrap around
ConsoleWrite(-9223372036854775807 - 3 & @LF) ;  9223372036854775806   0111111111111111111111111111111111111111111111111111111111111110
ConsoleWrite(-9223372036854775807 - 4 & @LF) ;  9223372036854775805   0111111111111111111111111111111111111111111111111111111111111101
ConsoleWrite(@LF)
ConsoleWrite(9223372036854775807     & @LF) ;   9223372036854775807   0111111111111111111111111111111111111111111111111111111111111111
ConsoleWrite(9223372036854775807 + 1 & @LF) ;  -9223372036854775808   1000000000000000000000000000000000000000000000000000000000000000  <-- wrap around
ConsoleWrite(9223372036854775807 + 2 & @LF) ;  -9223372036854775807   1000000000000000000000000000000000000000000000000000000000000001
ConsoleWrite(9223372036854775807 + 3 & @LF) ;  -9223372036854775806   1000000000000000000000000000000000000000000000000000000000000010
ConsoleWrite(9223372036854775807 + 4 & @LF) ;  -9223372036854775805   1000000000000000000000000000000000000000000000000000000000000011

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

certainly due to string conversion = bug

This was my conclusion too. I discovered this when passing the number to the Execute() function. I wasn't sure though, has anyone opened a ticket or shall I do it?

Edit
Actually it looks as if it's already been reported
https://www.autoitscript.com/trac/autoit/ticket/3017

No mention of string conversion in that ticket though. I added a comment regarding this.


 

Geez, compatibility, what hard ways you force us to walk thru.

Understatement!  :ermm:

Edited by czardas
Link to comment
Share on other sites

why do the top two work?

ConsoleWrite(int("-9223372036854775808" , 2) & @LF)
ConsoleWrite(number("-9223372036854775808" , 2) & @LF)
ConsoleWrite(-9223372036854775808 & @LF)

No internal conversion to string takes place in the top two lines - which supports the conclusion. Hmm I'm not sure about this actually. It's not making much sense to me right now.

Here's how I stumbled upon this - fortunately before I posted another broken example script.

ConsoleWrite((Execute(0x8000000000000000 & " - 0") = 0x8000000000000000 - 0) & @LF) ; False ???
ConsoleWrite((Execute(0x8000000000000000 & " - 0") = 0x8000000000000000 + 1) & @LF) ; True ^^

 

Edited by czardas
Link to comment
Share on other sites

There is indeed something wrong under the ice.

There is also something plain wrong with / and ^ operators acting on integers. I'll report about this as soon as I find time to fully characterize the issue. In short, such operation is currently put in (dirty) hands of floating-point and of course the result can be badly wrong because FP can't always deliver enough precision to represent the result. This despite the fact that it's almost impossible to run current OSes on hardware not featuring 80-bit FP but I ain't doing to dig further into FP guts. Arithmetic over integers should never deliver a FP result when it can be represented as an integer.

Also it's a shame that integral division doesn't deliver both the (integral) quotient and rest. @extended is a perfect receptacle for that.

Euclid, please, come back.

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

FYI I just changed ticket https://www.autoitscript.com/trac/autoit/ticket/3017 title to match the actual issue it brings. Hope this is OK.

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

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