Modify

#2642 closed Bug (No Bug)

The function Hex() returns the wrong value

Reported by: Cythor Owned by:
Milestone: Component: AutoIt
Version: 3.3.10.2 Severity: None
Keywords: Cc:

Description

The code says all what I mean.

$var = BitAND(1529, 65280) / 256 ; = 5
ConsoleWrite(Hex($var) & @CRLF) ; ?

Attachments (0)

Change History (8)

comment:1 by jchd18, on Jan 28, 2014 at 1:12:01 AM

$var = BitAND(1529, 65280) / 256 ; = 5
ConsoleWrite(VarGetType($var) & ' = 0x' & Hex($var) & ' = ' & $var & @CRLF) ; ?

See Hex() help.

comment:2 by BrewManNH, on Jan 28, 2014 at 1:16:34 AM

Why is it being turned into a Double though I think is the question. Neither number is a floating point so I don't understand why it's happening.

comment:3 by jchd18, on Jan 28, 2014 at 1:31:14 PM

Agreed, that would be the right subject for a ticket. But that was not the issue raised by he OP.

comment:4 by Melba23, on Jan 28, 2014 at 7:54:34 PM

Surely the result of any calculation involving a division has to be a double as AutoIt has no way of knowing that an integer will be returned and so must assume that the value will be fractional.

This code gives the same result:

$var = 256 * 5 / 256
ConsoleWrite(VarGetType($var) & ' = 0x' & Hex($var) & ' = ' & $var & @CRLF)

which to my eyes is entirely expected.

M23

comment:5 by anonymous, on Jan 28, 2014 at 9:53:46 PM

Turning 1/1 into a double is utter tech perversion, period.
1.0/1 or 1/1.0 as double is expected and necessary in some circumstances, but certainly not 1/1.

Anyway this isn't the place to discuss junk food.

comment:6 by jchd18, on Jan 28, 2014 at 10:12:53 PM

I keep being disconnected, but it was me above.
0/1 also a double, of course... geez.

comment:8 by Melba23, on Jun 6, 2014 at 3:30:10 PM

Resolution: No Bug
Status: newclosed

I am closing this ticket as there is no problem with Hex - the seemingly invalid returns are caused by the inadvertent use of doubles instead of integers as the argument. That is covered by this ticket:

http://www.autoitscript.com/trac/autoit/ticket/2729

M23

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


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