[Rust] Floating-Point Types in Rust

In this lesson we take a look at Floating-Point values and the f32 and f64 types. We'll also look at the different ways of defining and creating values of such types.

fn main() {

  // Floating-Point types
  //
  // f32: -3.4 * 10^38 to +3.4 * 38
  // f64: -1.8 * 10^308 to +1.8 *10^308

  let f = -1.2345;

  let f2 = 3.;

  let f3 = 0.34;

  let f4 = 1e4;

  let f5 = 32f32;

  let f6 = 231.452e-29f64;
}

 

posted @ 2024-02-20 02:20  Zhentiw  阅读(6)  评论(0)    收藏  举报