Search the Community
Showing results for tags 'dec'.
-
For some reason, I can't convert to Hex a Decimal color that has been calculated. For example, this works: Local $iColor = 3310546 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the expected output: $iColor (dec): 3310546, $iColor (hex): 3283D2 But if I want to take an average of several colors, I have a problem. For example this doesn't work: $iColor = (3310546 + 3310546) / 2 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the wrong output: $iColor (dec): 3310546, $iColor (hex): 000000 I observe this behavior after any processing of a decimal color. Is this a bug?
- 3 replies
-
- dec
- hex conversion
-
(and 1 more)
Tagged with:
-
Seems like Int function works incorrect sometimes. Int of binary data works fine on 1-byte data only. 2+ byte data always returns incorrect results. Int of 4-byte binary data and it's string representation: Int of 4-byte binary data returns bswap as result. Int64 of string representation of 4-byte binary data returns 32-bit signed integer. $bin = Binary('0xff'); 1 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd8'); 2 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d'); 3 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8a'); 4 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abc'); 5 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1'); 6 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5'); 7 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5ff'); 8 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) AutoIt 3.3.12.0 x86 and x64 OS: Win 7 x64 SP1