Complete the code to declare a 32-bit floating point variable.
let pi: [1] = 3.14f32;
The f32 type is used for 32-bit floating point numbers in Rust.
Complete the code to declare a 64-bit floating point variable.
let e: [1] = 2.71828;
The f64 type is used for 64-bit floating point numbers in Rust.
Fix the error in the code by choosing the correct floating point type.
let gravity: [1] = 9.81;
Rust supports f32 and f64 for floating point types. f64 is the correct 64-bit type.
Fill both blanks to create a vector of 32-bit floating point numbers.
let numbers: Vec<[1]> = vec![1.0f32, 2.0f32, 3.0f32]; let first: [2] = numbers[0];
f64 when the vector is f32.The vector holds f32 values, so the variable first must also be f32.
Fill all three blanks to create a function that returns a 64-bit floating point number.
fn calculate_area(radius: [1]) -> [2] { let pi: [3] = 3.14159; pi * radius * radius }
f32 and f64 types.The function uses f64 for the parameter, return type, and constant pi for precision.
