Computing.Net > Forums > Programming > java byte question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

java byte question

Reply to Message Icon

Name: tl1_mossman2
Date: April 25, 2004 at 23:07:50 Pacific
OS: windex
CPU/Ram: 3hz/1b
Comment:

I've a question... im begining to get into networking...

setting up an InetAddress, there's a constructor that takes a byte array...

i'd like to use bytes for construction, however, they seem to only take values to 127 (eighth byte indicating negative or not)... my question, anyway to construct a byte array containing more then 127 as a possible value per byte?

-just curious... seems kind of useless to put a byte array constructor into InetAddress if there's no way to get a value higher then 127...



Sponsored Link
Ads by Google

Response Number 1
Name: wharfie
Date: April 26, 2004 at 17:59:18 Pacific
Reply:

The maximum value of 7 bits is 127. As you already know the 8th bit is used to determine sign.

Binary 1111111 = 127

If you need to use values larger than 127 then use another data type, eg short, int, long.


0

Response Number 2
Name: gpp
Date: April 27, 2004 at 05:40:58 Pacific
Reply:

Just curious as to why you need a byte to hold more than that. A byte array should cover any address you can think of.


0

Response Number 3
Name: tl1_mossman2
Date: May 5, 2004 at 14:05:14 Pacific
Reply:

InetAddress "constructor" (can) use a byte array... but InetAddress's are from 0 to 255... so... bit unusual having a byte "constructor" that can only access addresses with bytes under 128...


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: java byte question

Java Method Question www.computing.net/answers/programming/java-method-question/14684.html

Java noob question www.computing.net/answers/programming/java-noob-question/13768.html

java BufferedReader question www.computing.net/answers/programming/java-bufferedreader-question/10020.html