Modify

Opened 12 years ago

Closed 12 years ago

#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, 12 years ago

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

See Hex() help.

comment:2 by BrewManNH, 12 years ago

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, 12 years ago

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

comment:4 by Melba23, 12 years ago

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, 12 years ago

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, 12 years ago

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

comment:7 by czardas, 12 years ago

The following post by me appears to be related.

http://www.autoitscript.com/forum/topic/161396-lamus/?p=1174073

comment:8 by Melba23, 12 years ago

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.