Float

Much as with other languages, floating point arithmetic can be performed in Rust. As with an integer variable, a floating point variable is defined for a 32-bit float as follows:

let pi = 3.14f32; 

For a 64-bit float, it will be defined as this:

let pi = 3.14f64; 

The variables are literal values. Another way to declare the size would be via types:

let pi: f32 = 3.14; 
If a type is omitted (for example, let x = 3.14), the variable will be declared as a 64-bit floating point variable.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset