[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about Data type in VB.NET



In-Reply-To: <20031022115713.10502.qmail@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

>In VB.NET if we declare an int by default from what I understand it is a 32 bit int size ranges from -2,147,483,648 through 2,147,483,647. The size range for short however is -32,768 through 32,767 and char is 0 through 65535 (unsigned) (msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vagrpdatatype.asp). 

correction; char is 1-256.

think of how these are stored in memory, int = 4 byte comparison(256*256*256*256=4294967296), short = two byte comparison(256*256=65536), char = 1 byte(256).

by default these casts are signed, making it half negative and half positive like you show, so if you don't want the negative aspect use something like: unsigned int = 4294967295(==-1,max).

basically, use an "unsigned short" for a port value..