mIRC Home    About    Download    Register    News    Help

Print Thread
#23261 08/05/03 09:27 PM
S
ScatMan
ScatMan
S
can any1 tell me what does those switches:
word, nword, long, nlong ?
the helpfile don't explain about them much

C
codemastr
codemastr
C
The word, nword, long, and nlong properties return values in host or network byte order.

that is, word returns it in word format (16bit) in host byte order, nword returns it in word format (16bit) in network byte order
long returns it in long format (32bit) in host byte order
nlong returns it in long format (32bit) in network byte order

Although from personal testing, I believe it always returns the same byte order no matter which one you use, but I could be mistaken.

S
ScatMan
ScatMan
S
what????????
i don't understand nothing
plz try to explain more and with examples

C
codemastr
codemastr
C
If you don't understand what byte order is, you're not going to understand my explanation. Byte order is basically where the MSB (Most signifigant byte) and the LSB (Least signifigant byte) is located. Network byte order is equivilent to Big-Endian format. This means the MSB is first and LSB is last. Host byte order is the opposite, it is Little-Endian, that is the MSB the last byte and the LSB is the first byte. For example consider the number 305419896. In hexidecimal notation this is 12345678. In network byte order it is ordered as: 0x12 0x34 0x56 0x78. In host byte order it is ordered as 0x78 0x56 0x34 0x12. As for the difference between word and long, generally a word is 2 bytes (16bits) where as a long is 4 bytes (32bits).

S
ScatMan
ScatMan
S
sorry, can't get that
(i know what is byte, bit etc)

C
codemastr
codemastr
C
Well if you didn't understand that, then there isn't much more I can do to make you understand it.

Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
I just love the way code simplifies things for us. Its so legible and comprehendable. grin

C
codemastr
codemastr
C
Well byte order isn't exactly meant to be easy to understand. It requires a knowledge of networking protocols as well as underlying processor architecture. Thats why in my post I said he probably wouldn't understand it. I could provide several URLs that provide information on byte order, but all of the ones I know of would be even more confusing than what I said.

Joined: Feb 2003
Posts: 2,737
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,737
If you have ever used a hex editor, this visual should help you understand better. The values below represent the contents of an 8 byte file.

01 00 00 00 02 00 03 00

word and long will read numbers from left to right, with the left being the least significant value and the right being the most significant. This is known as host byte-order, or little-endian. 01 00 00 00 == 1

nword and nlong will read numbers from right to left, this is known as network byte-order, or big-endian. 00 00 00 01 == 1 (this is least common, especially on x86 computers)

a WORD (sometimes known as an interger or int) is a 16bit or 2byte value. a LONG (sometimes known as DWORD) is a 32bit or 4byte value. Usually these values are "signed", meaning the most significant bit determines if the value is negative. Unsigned values cannot be negative, but can represent values twice as large.
And now with the examples...

01 00 00 00 02 00 03 00 - $bvar(&v,1).word == 1
01 00 00 00 02 00 03 00 - $bvar(&v,1).nword == 256
01 00 00 00 02 00 03 00 - $bvar(&v,1).long == 1
01 00 00 00 02 00 03 00 - $bvar(&v,1).nlong == 16777216

Can you guess what this would equal?

01 00 00 00 02 00 03 00 - $bvar(&v,5).long == ????????

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
S
ScatMan
ScatMan
S
first , i don't know what is hex editor
second, how did u get with .word from 01 00 to 1 ??

Joined: Feb 2003
Posts: 2,737
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,737
Sorry to doubt you codemastr.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
C
codemastr
codemastr
C
lol smile

Joined: Dec 2002
Posts: 3,015
P
Hoopy frood
Offline
Hoopy frood
P
Joined: Dec 2002
Posts: 3,015
Some things dont have a simple explanation, and the help file has to assume that if you need to use some advanced items that you have the background needed to understand how they work. For example, it would be very difficult for someone to give you a simple brief explanation of binary files or hex vs binary.


Link Copied to Clipboard