There are four scalar types, integers, floats, Booleans, and characters. Let's go over integer types first. There are a lot of them unsigned integers start with you followed by the number of bits the integer has consistent across all platforms except for you size you size is the size of the platform's pointer type and can represent every memory address in the process. It's also the type you will usually use to index into an array or vector signed integers are the exact same story, except they use AI for their prefix I for integer I presume, I size also has the same number of bits the platform's pointer type, the maximum I size value is the upper bound of object and array size. This ensures that I size can be used to calculate differences between pointers, and be able to address every byte within a value like a struct. If you don't annotate an integer literal Then it defaults to iE 32 because it's generally the fastest integer even on 64 bit architectures.
Now just because the types have the same number of bits on all architectures doesn't mean all types are supported on all architectures. a 16 bit microcontroller might only support these types. integer literals can be specified in a number of ways. decimal is as you would expect, hexadecimal begins with zero x octal begins with 00 binary begins with zero B, and a single unit byte can optionally be specified by be single quotes enclosing a UTF eight character in the ASCII range. This is pretty rare to use. In my experience, most people just use a decimal integer between zero and 255.
The terms you ate and byte are used interchangeably in rust, you'll hear bite all the time instead of UAT. The representations that take more than one digit can Have any number of ignored underscores inside them or at the end of them this is just for convenience and readability. For example, these are the same numbers with some underscores in places that we usually like. But you could also do this if you want it to the point is the underscores are ignored. Floating Point types are much simpler f 32 has 32 bits of precision, and F 64 has 64 bits of precision. f 64 is the default because it has more precision, but it can be really slow on less than 64 bit architectures.
So be careful with that. Floating Point literals follow the I triple E 754 standard but basically look like this. No special suffix is required, but you do always need to have at least one digit before the.so this is not a valid floating point literal, but this is because it has a digit in front of the DOP numerical literals can optionally include the type as a suffix. Usually when you want a specific type Type you will annotate a variable declaration and the type of the literal will be inferred, but it is also completely fine to suffix the literal with the type you want. This is especially useful if you want to pass a literal to a generic function that could accept multiple numeric types. This is one situation where underscores can really improve readability.
Now, for the Boolean type, the actual type is specified with bool. That's easy enough. The two Boolean literals are true and false. all lowercase Booleans are not integers. So don't try to use arithmetic on them. It won't work unless you can ask them to some integer type like this.
The character type is Miss named even though you specify it with care, it actually represents a single Unicode scalar value which could be anything from a character of our alphabet to a character of someone else's alphabet to an idea graph or a diacritic or an emoji or a non printable Unicode control. character that could represent anything from a sound to an action. A character is always four bytes, which effectively makes an array of characters, a UCS four or UTF 32 string. Character literals are specified using single quotes. And most important of all characters are fairly useless strings are UTF eight, and characters are not. So strings do not use characters internally source files are also UTF eight.
So chances are when you want to deal with a single character, it's going to be a UTF eight string, not a character literal. We'll talk about strings in a later video. In the next video, we'll talk about compound types.