i'm really confused
when you use Hex with 65535 it'll return FFFF (that's no problem)
but the problem is when you try with -1, it'll also return FFFF![]()
![]()
![]()
what's the problem ???VB Code:
Debug.Print Hex(-1) 'This will retrun FFFF Debug.Print Hex(65535) 'This will return FFFF too 'Or another way Debug.Print Hex(-1) = Hex(65535) 'this will return true 'i know this seems confusing (the =) but here the = is conditional 'it's not a = of a set statement (there is no problem with this = )
is it right mathematically ???
well i think it isn't right mathematically cause from my experience maths are always logical , and this is not logical beacause when you try to do the conversion in the other direction (Hexadecimal --> Decimal ) you won't know whether the origin was 65535 or -1
and another reson for findinf it not logical is that when using the classical way of converting any base to base 10 ( the number in the column from the right * the base ^ (The column number -1 ) + the same thing) you'll get that FFFF is 65535 not -1 but Val ("&HFFFF") = -1
Very confusedVB Code:
'the way of converting, it'll work with bases < 10 dim TheLastNumber for i = 0 to len ( TheNumber) -1 TheLastNumber = TheLastNumber + (mid(TheNumber , len(theNumber) -i ,1) ^ i) next i![]()
![]()
![]()
BTW the same thing happens with OCT
VB Code:
Debug.print Oct(-1) = Oct(65535) 'this will return true
any help ?????




)
Reply With Quote