There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Technology can never substitute for knowledge.
Originally posted by Christopher Young:
Because there's times when numbers don't have to be negative?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Technology can never substitute for knowledge.
Technology can never substitute for knowledge.
"I'm not back." - Bill Harding, Twister
Originally posted by Christopher Young:
Why is every argument against "just use signed ints" and not an actual reason for why the language is limited in this way? ...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Dale Carnegie:<br />"Most of the important things in the world have been accomplished<br />by people who have kept on trying when there seemed to be no hope at all."
Well, that [reading unsigned bytes] is supported in some ways. For example the DataInputStream class has methods like readUnsignedByte()
Technology can never substitute for knowledge.
Originally posted by Christopher Young:
but hasn't C++ solved such problems since they use functions very similar to Java's methods and such?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
i'll turn that question around. Why SHOULD java have support for unsigned integers?
Because unsigned numbers are not really necessary and just add an extra dimension of complexity to the Java language.
but if these were added to Java, then there would have to be added a whole set of rules about conversions and overloading as well.
This is only one example - there are lots of other issues that you could think of.
What about for instances in networking where the program is being passed unsigned numbers? Wouldn't it make sense to have support for that element of programming?
Well, that is supported in some ways. For example the DataInputStream class has methods like readUnsignedByte() which reads a byte and treats it as an unsigned byte, returning the result in an int. The return type needs to be bigger than the base type in this case (i.e. int is bigger than byte) because it needs to be able to handle the additional range of an unsigned byte.
In general the need for unsigned types is fairly rare in Java, and when it comes up, tricks like DataInputStream's methods work well enough.
Maybe this can explain the why?
]http://darksleep.com/player/JavaAndUnsignedTypes.html
Java was created to be powerful but not too complex.
"I'm not back." - Bill Harding, Twister
...the ninth bit from the end) will be zeroed.....
Originally posted by Kaydell Leavitt:
I don't understand what is meant by the "ninth bit".
A byte is always 8 bits, so how can a byte have "a ninth bit"?
"I'm not back." - Bill Harding, Twister
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|