Skip to content

Commit

Permalink
Clarify behavior of integer division. Fixes #2248.
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Jul 21, 2021
1 parent db430c2 commit f40c71f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn main() {

// division
let quotient = 56.7 / 32.2;
let floored = 2 / 3; // Results in 0

// remainder
let remainder = 43 % 5;
Expand Down
3 changes: 2 additions & 1 deletion src/ch03-02-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ Floating-point numbers are represented according to the IEEE-754 standard. The

Rust supports the basic mathematical operations you’d expect for all of the
number types: addition, subtraction, multiplication, division, and remainder.
The following code shows how you’d use each one in a `let` statement:
Integer division rounds down to the nearest integer. The following code shows
how you’d use each numeric operation in a `let` statement:

<span class="filename">Filename: src/main.rs</span>

Expand Down

0 comments on commit f40c71f

Please sign in to comment.