﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2992	Int, Dec, Number return incorrect results when used with binary and string data	timsky		"Forum bug report: http://www.autoitscript.com/forum/topic/167633-int-returns-incorrect-results

1) '''Int''' and '''Number''' of '''binary''' data works fine on 1-byte data only. 2+ byte '''binary''' data always returns incorrect results.
2) Case of 4-byte (32 bit) binary data and it's string representation:
   a) '''Int''' and '''Number''' of 4-byte '''binary''' data returns wrong result.
   b) '''Int''' (64 bit flag) of '''string''' representation of 4-byte '''binary''' data returns 32-bit signed integer. Example string ""0xffd88d8a"" return '''-2585206''' instead of '''4292382090'''.
   c) Only '''Dec''' (64 bit flag) and '''Number''' (double flag) return correct results.
3) '''Number''' (double flag) does not work on '''binary''' data always. It returns 0.
4) '''Number''' (double flag) stop working on '''string''' data starting 5+ byte data.  It returns 0.
5) '''Dec''' (double flag) doesn't work always. It returns strange numbers like '''1.25986739689518e-321''' for ""0xff"".

Demo code:
{{{
Global $aBin[] = [""0xff"", '0xffd8', '0xffd88d', '0xffd88d8a', '0xffd88d8abc', '0xffd88d8abcd1', '0xffd88d8abcd1e5', '0xffd88d8abcd1e5ff']

For $i = 0 To UBound($aBin) - 1
    $real_str = $aBin[$i]
    $real_bin = Binary($real_str)
    ; MsgBox(0, VarGetType($real_str), VarGetType($real_bin))

    $sData = 'Hex: ' & @TAB & @TAB & $real_str & @LF & _
            'Binary: ' & @TAB & @TAB & StringLower($real_bin) & @LF & _
            'Dec32: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 1) & @LF & _	; added
            'Dec:  (auto)' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2)) & @LF & _	; Renamed
            'Dec64: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 2) & @LF & _	; added
            'Dec (double): ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 3) & @LF & _	; added
            'Number32 <- String: ' & @TAB & @TAB & Number($real_str, 1) & @LF & _	; added
            'Number <- String:  (auto)' & @TAB & @TAB & Number($real_str) & @LF & _	; added
            'Number64 <- String: ' & @TAB & @TAB & Number($real_str, 2) & @LF & _	; added
            'Number (double) <- String: ' & @TAB & @TAB & Number($real_str, 3) & @LF & _	; added
            'Number32 <- Binary ' & @TAB & @TAB & Number($real_bin, 1) & @LF & _	; added
            'Number <- Binary  (auto)' & @TAB & @TAB & Number($real_bin) & @LF & _	; added
            'Number64 <- Binary ' & @TAB & @TAB & Number($real_bin, 2) & @LF & _	; added
            'Number (double) <- Binary ' & @TAB & @TAB & Number($real_bin, 3) & @LF & _	; added
            'Int32: ' & @TAB & @TAB & Int($real_str, 1) & @LF & _
            'Int (auto): ' & @TAB & @TAB & Int($real_str) & @LF & _
            'Int64: ' & @TAB & @TAB & Int($real_str, 2) & @LF & _
            'Int32 <- String: ' & @TAB & Int(String($real_str), 1) & @LF & _
            'Int (auto) <- String: ' & @TAB & Int(String($real_str)) & @LF & _
            'Int64 <- String: ' & @TAB & Int(String($real_str), 2) & @LF & _
            'Int32 <- Binary: ' & @TAB & Int($real_bin, 1) & @LF & _
            'Int (auto) <- Binary: ' & @TAB & Int($real_bin) & @LF & _
            'Int64 <- Binary: ' & @TAB & Int($real_bin, 2)

    MsgBox(524288, $real_str & "" - "" & BinaryLen($real_str) & ' bytes', $sData)

Next
}}}


So right now the only working way to interpret '''Binary''' data in 8-64 bit range is '''Dec''' with 64 bit flag set.
And bugfix for 3.3.12.0 ""Fixed #2581: Dec() wasn't working correctly for flags 0, 1, 2"" seems like is not fully completed.

AutoIt 3.3.12.0 / 3.3.13.19. x86 and x64
OS: Win 7 x64 SP1"	Bug	closed		AutoIt	3.3.12.0	None	No Bug	Int, Dec, Number	
