From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Boolean data type and operations - Rust Tutorial
From the course: Rust Essential Training
Boolean data type and operations
- [Instructor] In addition to integer and floating point data types, Rust has another primitive data type called a Boolean which can have one of two possible values either true or false. We can use the same set of logical operators we saw in the previous video to evaluate Boolean values with NOT, AND, OR an XOR. The bit value of one corresponds to true and zero corresponds to false. In fact, if you cast the Boolean data type into an integer the resulting value will be a one or a zero. This example demonstrates those four logical operations applied to the Boolean variables a and b, which are initialized on lines two and three to the values true and false respectively. Lines four, through eight, then display the values of a and b as well as the results of applying the NOT and OR an XOR operations. The NOT operator is represented with an exclamation mark or bang. The AND operator is an ampersand or is a vertical pipe. An…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Declaring variables5m 46s
-
Integer data types6m 51s
-
Floating-point data types5m 34s
-
Arithmetic operations6m 37s
-
Formatting print statements5m 40s
-
Bitwise operations10m 46s
-
Boolean data type and operations5m 4s
-
Comparison operations3m 5s
-
Char data types2m 36s
-
Challenge: Find the average1m 20s
-
Solution: Find the average3m 20s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-