From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Floating-point data types - Rust Tutorial
From the course: Rust Essential Training
Floating-point data types
- The integer data types are not intended to store fractional values. If you need to store a number with decimal places, you should use a floating-point type. Rust supports two floating point data types. A 32 bit version, and a 64 bit version. You may hear these referred to as single precision and double precision respectively. Floating-point values in rust are stored in several parts including a fractional value and an exponential value that's used to scale it. The largest possible 64 bit floating-point value is 1.7 times 10 to the power of 308. So that exponent allows us to represent a huge range up to some really, really big numbers. However, even though that number is huge in magnitude, the fractional component has a finite amount of precision. So we're limited in the number of significant digits or decimal places we can represent. As an example, let's consider how PI would be stored as a floating point value. PI is 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
-
(Locked)
Integer data types6m 51s
-
(Locked)
Floating-point data types5m 34s
-
(Locked)
Arithmetic operations6m 37s
-
(Locked)
Formatting print statements5m 40s
-
Bitwise operations10m 46s
-
(Locked)
Boolean data type and operations5m 4s
-
(Locked)
Comparison operations3m 5s
-
Char data types2m 36s
-
(Locked)
Challenge: Find the average1m 20s
-
(Locked)
Solution: Find the average3m 20s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-