This lesson talks about Integer types in Rust and that there are unsigned and signed integers.
It also explains how every the type names are composed of "u" and "i", for unsigned and signed respectively, followed by their with in bits. So u8
is an unsigned integer that can store values up to 8 bits (0 - 255).
Hi!
i
makes most sense as it probably stands for integer.2a) That is correct!
2b) I think if it you at it this way, your argument would be valid :D Sorry for the confusion.
isize
or usize
will give you always the biggest space on the underlying architecture. I guess there could be cases where, on a 64bit system, i/u32
would be too little, so using i/usize
is a more flexible option.
Several "dumb" questions:
i
instead ofs
for signed integers?2a) 2^8 = 256, not 255, but the upper limit for
u8
is given as 255; is that because 0 is also included, making 256 values total? (Ditto on the other types' upper bounds.)2b) So should the comment really say
0 to 2^8-1
, like the signed examples do? (And so on for the other unsigned comments.)usize
or anisize
given that their capacity changes depending on the system?