Modify

#3760 closed Bug (Fixed)

Number() bug with oversized integer values

Reported by: jchd18 Owned by: Jon
Milestone: 3.3.15.5 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

Number($s) erroneously converts values outside [MinInt64, MaxInt64] to MinInt64 or MaxInt64.

MinInt64 = -9223372036854775808
MaxInt64 = 9223372036854775807

Example:

Number("22222222222222222222222222222222")  ; returns 9223372036854775807

Workaround version returning a FP values in such case:

Func _Number($s)
	Local $a = StringRegExp($s, "^([-+]?)0*(\d+)$", 1)
	If Not @error Then
		Local $l = StringLen($a[1])
		; in case the int is oversized
		If $l > 19 Or ($a[0] <> "-" And $a[1] > "9223372036854775807") Or ($a[0] = "-" And $a[1] > "9223372036854775808") Then Return Number($s & ".0")
	EndIf
	Return Number($s)
EndFunc

Attachments (0)

Change History (5)

comment:1 by Jpm, on Aug 10, 2020 at 12:47:08 PM

Owner: set to Jpm
Status: newassigned

Hi, Fis send to Jon

comment:2 by anonymous, on Sep 27, 2020 at 10:26:58 PM

Local $dNumber6 = Number("24autoit") ; Returns 24

this not work, return 0 only

in reply to:  2 comment:3 by jchd18, on Sep 28, 2020 at 7:20:04 PM

Local $dNumber6 = Number("24autoit") ; Returns 24

this not work, return 0 only

Untrue. The code correctly sets $dNumber6 to 24.
Please use the help forum instead.

in reply to:  2 comment:4 by Jpm, on Sep 29, 2020 at 3:32:56 PM

Replying to anonymous:

Local $dNumber6 = Number("24autoit") ; Returns 24

this not work, return 0 only

please don't use an open ticket for something else this ticket is with oversized number

comment:5 by Jon, on Feb 27, 2022 at 3:02:07 PM

Milestone: 3.3.15.5
Owner: changed from Jpm to Jon
Resolution: Fixed
Status: assignedclosed

Fixed by revision [12635] in version: 3.3.15.5

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.