Floats

Last updated

What is Floats?

In Rust, floats are a primitive data types used to represent floating-point numbers. They are defined as numerical values with fractional components. Floating-point numbers are represented according to the IEEE-754 standard.

Rust supports two types of floating-point numbers: f32 and f64. These are 32-bit and 64-bit in size, respectively.

  • f32 (binary32 type defined in IEEE-754-2008) is a single-precision float, which means is less precise than f64 type.
  • f64 (binary64 type defined in IEEE-754-2008) has double precision. The default type is f64 because on modern CPUs it’s roughly the same speed as f32 but allows more precision.

Both f32 and f64 represent negative, zero and positive floating-point values.

Free resources to learn Floats

More in stage 5: Testing

Floats: common questions

Can I learn Floats in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Floats in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Floats tutorial for beginners?

It is lesson 26 of 122 in the free Rust roadmap, in stage 5, Testing. If you are new to Rust, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me