From 89d22aa1272ad97905e36cadfa43e44c2940c562 Mon Sep 17 00:00:00 2001 From: Jhonatan Mustiola <152746443+hiahir357@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:22:51 -0400 Subject: [PATCH] Update 101-floats.md (#5859) Added more links. Content keeps the copy --- .../103-data-structures/101-floats.md | 14 ++++++++++++-- .../103-data-structures/102-boolean.md | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.md b/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.md index e25a10dff..e32a8048d 100644 --- a/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.md +++ b/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.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) \ No newline at end of file +- [@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) diff --git a/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md b/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md index a6d24a559..6f5f92192 100644 --- a/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md +++ b/src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md @@ -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) \ No newline at end of file +- [@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)