What is the concept of signed integers in a programming language?

5

I would like to clarify the meaning of the term "signed integer".

I'm researching on protocols, to build one in Java, and over and over meeting the term. I do not know what it's all about.

I've always heard of primitive types, for example in Java: int , float , double , ...

But for me the term is new!

Why is it said that Java "does not have" such unsigned integers ?

And what's the difference between an "signed integer" and an "unsigned integer"?

    
asked by anonymous 10.06.2017 / 23:48

1 answer

10

If signed integer is meaning marked integer, it is the type normally used in Java. The number has a bit to indicate whether it is positive or negative.

Many languages have unsigned types where this bit is not considered, so it only stores positive numbers, but can go up to twice the same type with signal. Java is not one of these languages. They considered this to be a simplification in language.

It even makes sense because it is common for people to use it wrong and in a few situations they are needed in high-level applications. But where you need it can not use, if you need to interoperate with external code you will have difficulties.

In C #, for example there is ushort (up to 65535), uint (up to 4294836225) ulong (up to 18445618199572250625), byte (up to 255) is already unrecognized, and sbyte is that it uses a signal.

Then the signal described here is + or -

    
11.06.2017 / 00:03