Signed and Unwritten Integers in Ruby

As in C, does ruby ​​have signed and unsigned integers, and if it does, does this String class length method return a signed integer? (Since in C, an integer, if not specified, is understood to be signed)

+4
source share
3 answers

Ruby implements integers in such a way that the distinction signed by / unsigned does not matter, since Ruby integers automatically expand into BigNum (arbitrary integer lengths) when applicable.

This effectively prevents integer overflows, which is IMHO the main reason people care about subscribing in languages ​​with fixed-size integers such as C.

+7
source

Since types are dynamic in Ruby, forcing the use of Ruby for a numerical value as a specific format does not make sense.

Ruby will store integers internally. So let Ruby decide how to keep your number.

+2
source

room

the documentation tells you:

Ruby supports integers and floating point numbers. Integers can be of any length (up to the maximum determined by the amount of free memory in your system).

These integers are always signed.

+1
source

All Articles