mIRC Home    About    Download    Register    News    Help

Print Thread
Float ? 4bytes string.. pls help me :( #147821 24/04/06 05:42 PM
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
Re: Float ? 4bytes string.. pls help me :( #147822 24/04/06 08:07 PM
Joined: Sep 2005
Posts: 116
I
Im2good4u Offline
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

Re: Float ? 4bytes string.. pls help me :( #147823 24/04/06 10:16 PM
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
Re: Float ? 4bytes string.. pls help me :( #147824 24/04/06 10:18 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
What makes you think it represents -2?

Re: Float ? 4bytes string.. pls help me :( #147825 25/04/06 02:06 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
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

Re: Float ? 4bytes string.. pls help me :( #147826 25/04/06 10:56 AM
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
Re: Float ? 4bytes string.. pls help me :( #147827 25/04/06 03:31 PM
Joined: Sep 2005
Posts: 116
I
Im2good4u Offline
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