mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2005
Posts: 40
K
Karas Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Jul 2005
Posts: 40
Hi guys, i have this binvar: 254 255 255 255 78 190 58 67

that must be: -2

how can i traslate this to -2 ? O_o

Thx wink


j0k3r @ k4s.ch
Joined: Sep 2005
Posts: 116
I
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
hmm depents on wut charecter type is used ?

i tink its 32 bits charecters

i dunno u ned some kind of charecter table to lok it up

Joined: Jul 2005
Posts: 40
K
Karas Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Jul 2005
Posts: 40
that's not the problem (to view a character simply use $chr(num) )

254 255 255 255 78 190 58 67 ---> þÿÿÿN¾:C

Dump:
index char byte
132 --> þ --> 254
133 --> ÿ --> 255
134 --> ÿ --> 255
135 --> ÿ --> 255
136 --> N --> 78
137 --> ¾ --> 190
138 --> : --> 58
139 --> C --> 67

The problem is that the 8 bytes represent the value -2 .. or I think so..


j0k3r @ k4s.ch
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
What makes you think it represents -2?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
The 254 255 255 255 is -2 the following 78 190 58 67 could be anything at all, i doubt it directly relates to the same thing.

the 254 255 255 255 is a 32bit signed integer using LSB to MSB (least to most significanat byte order "small ended")

If you break it down as follows
byteA = 254
byteB = 255
byteC = 255
byteD = 255

the calculation is...
var value = $calc((byteA) + (byteB * 256) + (byteC * 65536) + ($and(byteD,127) * 16777216) + (($and(byteD,128) / 128) * -2147483648))

ByteD has its highest bit removed and is multiplied by 16777216 ( 256*256*256)
Following that should the highest bit of ByteD be ON then -2147483648 is added to the total, this essentially is the value of the highest bit (128*256*256*256) but negitive, this allows for values from -2147483648 to 2147483647

Joined: Jul 2005
Posts: 40
K
Karas Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Jul 2005
Posts: 40
Quote:
The 254 255 255 255 is -2 the following 78 190 58 67 could be anything at all, i doubt it directly relates to the same thing.

the 254 255 255 255 is a 32bit signed integer using LSB to MSB (least to most significanat byte order "small ended")

If you break it down as follows
byteA = 254
byteB = 255
byteC = 255
byteD = 255

the calculation is...
var value = $calc((byteA) + (byteB * 256) + (byteC * 65536) + ($and(byteD,127) * 16777216) + (($and(byteD,128) / 128) * -2147483648))

ByteD has its highest bit removed and is multiplied by 16777216 ( 256*256*256)
Following that should the highest bit of ByteD be ON then -2147483648 is added to the total, this essentially is the value of the highest bit (128*256*256*256) but negitive, this allows for values from -2147483648 to 2147483647


You are the man !
Thx a lot, it works fine ^_^


j0k3r @ k4s.ch
Joined: Sep 2005
Posts: 116
I
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
Dahm how could i have forgotten then :x i had it all at school


Link Copied to Clipboard