Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signed and Unsigned Integers in Ruby

Tags:

c

integer

ruby

Like C , does ruby have signed and unsigned integers and if it does then does that mean length method of String class return signed integer ? (Since in C integer if not specified implies signed)

like image 949
user1484793 Avatar asked Mar 12 '13 11:03

user1484793


1 Answers

Ruby implements integers in such a way that the distinction signed/unsigned is irrelevant, as Ruby integers extend automatically into BigNum (arbitrary length integers) when applicable.

This effectively prevents integer overflow, which is IMHO the main reason why people care about signedness in languages with fixed-size integers like C.

like image 189
Vincent Fourmond Avatar answered Sep 21 '22 01:09

Vincent Fourmond