Skip to content

Commit a808c7d

Browse files
authored
Merge pull request #337 from YichiZhang0613/fix_inconsistency
Fix wrong comment and add assertion
2 parents a3a2c9f + b252f12 commit a808c7d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

factorion-math/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "factorion-math"
3-
version = "1.0.3"
3+
version = "1.0.4"
44
edition = "2024"
55
description = "The math (factorials and related functions) used by factorion"
66
license = "MIT"

factorion-math/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ pub fn approximate_termial_digits_float(k: u32, n: Float) -> Integer {
339339
/// Will panic if `x` is not finite.
340340
pub fn adjust_approximate((x, e): (Float, Integer)) -> (Float, Integer) {
341341
let prec = x.prec();
342-
let (extra, _) = (x.clone().ln() / Float::with_val(prec, 10).ln())
342+
if x == 0.0 {
343+
return (Float::with_val(prec, 0), Integer::ZERO.clone());
344+
}
345+
let (extra, _) = (x.clone().abs().ln() / Float::with_val(prec, 10).ln())
343346
.to_integer_round(rug::float::Round::Down)
344347
.unwrap_or_else(|| panic!("Got non-finite number, x was {x}"));
345348
let x = x / (Float::with_val(prec, 10).pow(extra.clone()));

0 commit comments

Comments
 (0)