Update 101-floats.md (#5859)

Added more links. Content keeps the copy
pull/5871/head
Jhonatan Mustiola 5 months ago committed by GitHub
parent cb8f380dc0
commit 89d22aa127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.md
  2. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md

@ -1,7 +1,17 @@
# Floats
In Rust, `floats` are used to represent floating-point numbers. They are defined as numerical values with fractional components. Rust supports two types of floating-point numbers: `f32` and `f64`. These are 32-bit and 64-bit in size, respectively. `f32` is a single-precision float, while `f64` has double precision. The default type is `f64` because on modern CPUs it’s roughly the same speed as `f32` but allows more precision. You can define a float in Rust like so: `let x: f32 = 3.0;`.
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.
Learn more from the following links:
- [@article@Floating-Point Types](https://rust-book.cs.brown.edu/ch03-02-data-types.html#floating-point-types)
- [@video@Rust Tutorial - Floating-Points](https://www.youtube.com/watch?v=t047Hseyj_k&t=335s)
- [@official@f32 - Rust](https://doc.rust-lang.org/std/primitive.f32.html)
- [@article@IEEE-754 Standard](https://en.wikipedia.org/wiki/IEEE_754)
- [@article@Floating-Point Types](https://rust-book.cs.brown.edu/ch03-02-data-types.html#floating-point-types)

@ -1,7 +1,9 @@
# Boolean
`Boolean` in Rust is a basic data type that encapsulates the truth value. It is represented by `bool` keyword and can hold two values either `true` or `false`. Rust includes `boolean` as its primitive data type and operations like logical `AND (&&)`, logical `OR (||)`, and logical `NOT (!)` can be performed on these types of values. Boolean is primarily used in conditional statements like `if`, `while` etc. For example, `let is_raining: bool = true;` where `is_raining` is a boolean variable holding the value `true`.
`Boolean` in Rust is a primitive data type that encapsulates the truth value. It is represented by `bool` keyword and can hold two values either `true` or `false`. If you cast a bool into an integer, `true` will be `1` and `false` will be `0`. Operations like logical `AND (&&)`, logical `OR (||)`, and logical `NOT (!)` can be performed on these types of values. Boolean is primarily used in conditional statements like `if`, `while` etc. For example, `let is_raining: bool = true;` where `is_raining` is a boolean variable holding the value `true`.
Learn more from the following links:
- [@article@The Boolean Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-boolean-type)
- [@video@Rust Tutorial - Booleans](https://www.youtube.com/watch?v=t047Hseyj_k&t=388s)
- [@article@The Boolean Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-boolean-type)
- [@official@bool - Rust](https://doc.rust-lang.org/std/primitive.bool.html)

Loading…
Cancel
Save