Modify

Opened 9 years ago

Closed 9 years ago

#3235 closed Bug (No Bug)

Floor isn't accurate

Reported by: TommyDDR Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description

I recently need to count the numbers of digits in a number, so i do my stuff with Log10 and i found a problem :

Local $log10_1000 = Log(1000)/Log(10)        ; Log(1000)/Log(10) = Log10(1000) = 3
Local $floor_log10_1000 = Floor($log10_1000) ; Floor(3) = 3
Local $int3 = Int(3)                         ; Int(3) = 3
Local $floor_int3 = Floor($int3)             ; Floor(3) = 3
ConsoleWrite($log10_1000 & @CRLF)            ; Display 3
ConsoleWrite($floor_log10_1000 & @CRLF)      ; Display 2 ??
ConsoleWrite($int3 & @CRLF)                  ; Display 3
ConsoleWrite($floor_int3 & @CRLF)            ; Display 3

Floor(Log(1000)/Log(10)) display 2 instead of 3.

Attachments (0)

Change History (1)

comment:1 Changed 9 years ago by Melba23

  • Resolution set to No Bug
  • Status changed from new to closed

Dividing in AutoIt automatically results in a Double (floating point) return value. In this case $log10_1000 does not hold the exact value 3 as you can see by running this line at the end of your script:

ConsoleWrite(Hex($log10_1000) & " - " & Hex($int3) & @CRLF)

which returns

4007FFFFFFFFFFFF - 00000003

So as the $log10_1000 variable actually holds a value slightly less than 3, Floor correctly returns 2. No bug.

Could I suggest opening a forum thread when you next come across a floating point "error" like this - they are rarely bugs.

M23

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.