-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from vic1707/factorials
Factorials
- Loading branch information
Showing
14 changed files
with
304 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Crate imports */ | ||
use super::macros::assert_f64_eq; | ||
use crate::utils::factorial::factorial; | ||
|
||
#[test] | ||
fn test_float_factorial() { | ||
// negatives | ||
assert!(factorial(-f64::INFINITY).is_nan()); | ||
assert!(factorial(-5.0).is_nan()); | ||
assert!(factorial(-2.5).is_nan()); | ||
assert!(factorial(-1.0).is_nan()); | ||
assert_f64_eq!(factorial(-0.0), 1.0); | ||
// positives | ||
assert_f64_eq!(factorial(0.0), 1.0); | ||
assert_f64_eq!(factorial(1.0), 1.0); | ||
assert!(factorial(2.5).is_nan()); | ||
assert_f64_eq!(factorial(2.0), 2.0); | ||
assert_f64_eq!(factorial(5.0), 120.0); | ||
// approaching the limit | ||
assert_f64_eq!(factorial(169.0), 4.269_068_009_004_702_7e304); | ||
assert_f64_eq!(factorial(170.0), 7.257_415_615_307_994e306); | ||
// at the limit | ||
assert!(factorial(171.0).is_infinite()); | ||
assert!(factorial(f64::INFINITY).is_infinite()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* Modules */ | ||
mod factorial; | ||
mod issues; | ||
mod macros; | ||
mod parser; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.