From 7806754d87fb155e7b16d5753a3d277eab2fa46b Mon Sep 17 00:00:00 2001 From: Aras14HD Date: Sat, 7 Mar 2026 20:28:17 +0100 Subject: [PATCH] =?UTF-8?q?make=20calculations=20more=20consistent=20parse?= =?UTF-8?q?=20small=20"digits"s=20and=20"tower"s=20as=20integer=20calculat?= =?UTF-8?q?e=20more=20exact=20termial=20of=20"digits"=20do=20not=20write?= =?UTF-8?q?=201=20=C3=97=20in=20truncate=20do=20not=20return=20rough=20as?= =?UTF-8?q?=20true=20in=20truncate=20when=20only=20zeroes=20were=20cut=20o?= =?UTF-8?q?nly=20turn=20"approx"=20and=20"digits"=20into=20integers=20when?= =?UTF-8?q?=20below=20integer=5Fcontruction=5Flimit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 6 +-- factorion-bot-discord/Cargo.toml | 4 +- factorion-bot-reddit/Cargo.toml | 4 +- factorion-lib/Cargo.toml | 2 +- factorion-lib/src/calculation_results.rs | 49 ++++++++++++++++++------ factorion-lib/src/calculation_tasks.rs | 47 ++++++++++++++++------- factorion-lib/src/parse.rs | 39 +++++++++++++++---- factorion-lib/tests/integration.rs | 30 ++++++++++++--- 8 files changed, 135 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97f87dde..e62f4c36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "factorion-bot-discord" -version = "2.4.0" +version = "2.4.1" dependencies = [ "anyhow", "dotenvy", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "factorion-bot-reddit" -version = "5.5.0" +version = "5.5.1" dependencies = [ "anyhow", "base64 0.22.1", @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "factorion-lib" -version = "4.4.0" +version = "4.4.1" dependencies = [ "arbtest", "chrono", diff --git a/factorion-bot-discord/Cargo.toml b/factorion-bot-discord/Cargo.toml index dc3805d0..c97e0d99 100644 --- a/factorion-bot-discord/Cargo.toml +++ b/factorion-bot-discord/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-discord" -version = "2.4.0" +version = "2.4.1" edition = "2024" description = "factorion-bot (for factorials and related) on Discord" license = "MIT" @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math", "discord"] categories = ["mathematics", "web-programming", "parser-implementations"] [dependencies] -factorion-lib = { path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"] } +factorion-lib = { path = "../factorion-lib", version = "4.4.1", features = ["serde", "influxdb"] } serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] } tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "time"] } dotenvy = "^0.15.7" diff --git a/factorion-bot-reddit/Cargo.toml b/factorion-bot-reddit/Cargo.toml index e9e7f720..7eb96a4e 100644 --- a/factorion-bot-reddit/Cargo.toml +++ b/factorion-bot-reddit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-reddit" -version = "5.5.0" +version = "5.5.1" edition = "2024" description = "factorion-bot (for factorials and related) on Reddit" license = "MIT" @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math"] categories = ["mathematics", "web-programming", "parser-implementations"] [dependencies] -factorion-lib = {path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"]} +factorion-lib = {path = "../factorion-lib", version = "4.4.1", features = ["serde", "influxdb"]} reqwest = { version = "0.12.28", features = ["json", "native-tls"], default-features = false } serde = { version = "1.0.219", default-features = false, features = ["derive"] } serde_json = "1.0.140" diff --git a/factorion-lib/Cargo.toml b/factorion-lib/Cargo.toml index f40cb221..95e8dd38 100644 --- a/factorion-lib/Cargo.toml +++ b/factorion-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-lib" -version = "4.4.0" +version = "4.4.1" edition = "2024" description = "A library used to create bots to recognize and calculate factorials and related concepts" license = "MIT" diff --git a/factorion-lib/src/calculation_results.rs b/factorion-lib/src/calculation_results.rs index 6b350448..0c387cb7 100644 --- a/factorion-lib/src/calculation_results.rs +++ b/factorion-lib/src/calculation_results.rs @@ -1,5 +1,7 @@ //! This module handles the formatting of the calculations (`The factorial of Subfactorial of 5 is`, etc.) +use factorion_math::rug::Complete; +use factorion_math::rug::integer::IntegerExt64; #[cfg(any(feature = "serde", test))] use serde::{Deserialize, Serialize}; @@ -583,11 +585,16 @@ fn truncate(number: &Integer, consts: &Consts) -> (String, bool) { .to_integer_round(crate::rug::float::Round::Down) .unwrap() .0; - let truncated_number: Integer = &number - / (Float::with_val(prec, 10) - .pow((length.clone() - consts.number_decimals_scientific - 1u8).max(Integer::ZERO)) - .to_integer() - .unwrap()); + let ten_exp = Integer::u64_pow_u64( + 10, + (length.clone() - consts.number_decimals_scientific - 1u8) + .max(Integer::ZERO) + .to_u64() + .unwrap(), + ) + .complete(); + let rough = !number.is_divisible(&ten_exp); + let truncated_number: Integer = &number / ten_exp; let mut truncated_number = truncated_number.to_string(); if truncated_number.len() > consts.number_decimals_scientific { round(&mut truncated_number); @@ -609,7 +616,11 @@ fn truncate(number: &Integer, consts: &Consts) -> (String, bool) { truncated_number.insert(0, '-'); } if length > consts.number_decimals_scientific + 1 { - (format!("{truncated_number} × 10^{length}"), true) + if truncated_number == "1" { + (format!("10^{length}"), rough) + } else { + (format!("{truncated_number} × 10^{length}"), rough) + } } else { (orig_number.to_string(), false) } @@ -806,23 +817,39 @@ mod tests { &consts ) .0, - "1 × 10^300" + "10^300" + ); + assert_eq!( + truncate( + &Integer::from_str(&format!("1{}", "0".repeat(300))).unwrap(), + &consts + ) + .1, + false + ); + assert_eq!( + truncate( + &Integer::from_str(&format!("2{}", "0".repeat(300))).unwrap(), + &consts + ) + .0, + "2 × 10^300" ); assert_eq!( truncate( - &-Integer::from_str(&format!("1{}", "0".repeat(300))).unwrap(), + &-Integer::from_str(&format!("2{}", "0".repeat(300))).unwrap(), &consts ) .0, - "-1 × 10^300" + "-2 × 10^300" ); assert_eq!( truncate( - &Integer::from_str(&format!("1{}", "0".repeat(2000000))).unwrap(), + &Integer::from_str(&format!("2{}", "0".repeat(2000000))).unwrap(), &consts ) .0, - "1 × 10^2000000" + "2 × 10^2000000" ); } diff --git a/factorion-lib/src/calculation_tasks.rs b/factorion-lib/src/calculation_tasks.rs index b433a0c1..354328c9 100644 --- a/factorion-lib/src/calculation_tasks.rs +++ b/factorion-lib/src/calculation_tasks.rs @@ -132,9 +132,9 @@ impl CalculationJob { let prec = consts.float_precision; let calc_num = match num { CalculationResult::Approximate(base, exponent) => { - let res = base.as_float() * Float::with_val(prec, 10).pow(&exponent); - if Float::is_finite(&(res.clone() * math::APPROX_FACT_SAFE_UPPER_BOUND_FACTOR)) { - res.to_integer().unwrap() + if exponent <= consts.integer_construction_limit { + let x: Float = base.as_float() * Float::with_val(prec, 10).pow(&exponent); + x.to_integer().unwrap() } else { return Some(if base.as_float() < &0.0 { CalculationResult::ComplexInfinity @@ -143,7 +143,11 @@ impl CalculationJob { (Float::from(base), exponent), -level as u32, ); - CalculationResult::Approximate(termial.0.into(), termial.1) + if termial.0 == 1 { + CalculationResult::ApproximateDigits(false, termial.1) + } else { + CalculationResult::Approximate(termial.0.into(), termial.1) + } } else { let mut exponent = exponent; exponent.add_from(math::length(&exponent, prec)); @@ -152,17 +156,32 @@ impl CalculationJob { } } CalculationResult::ApproximateDigits(was_neg, digits) => { - return Some(if digits.is_negative() { - CalculationResult::Float(Float::new(prec).into()) - } else if was_neg { - CalculationResult::ComplexInfinity - } else if level < 0 { - CalculationResult::ApproximateDigits(false, (digits - 1) * 2 + 1) + if digits <= consts.integer_construction_limit { + let x: Float = Float::with_val(prec, 10).pow(digits.clone() - 1); + x.to_integer().unwrap() } else { - let mut digits = digits; - digits.add_from(math::length(&digits, prec)); - CalculationResult::ApproximateDigitsTower(false, false, 1.into(), digits) - }); + return Some(if digits.is_negative() { + CalculationResult::Float(Float::new(prec).into()) + } else if was_neg { + CalculationResult::ComplexInfinity + } else if level < 0 { + let mut one = Float::with_val(consts.float_precision, 1); + if was_neg { + one *= -1; + } + let termial = + math::approximate_approx_termial((one, digits), -level as u32); + if termial.0 == 1 { + CalculationResult::ApproximateDigits(false, termial.1) + } else { + CalculationResult::Approximate(termial.0.into(), termial.1) + } + } else { + let mut digits = digits; + digits.add_from(math::length(&digits, prec)); + CalculationResult::ApproximateDigitsTower(false, false, 1.into(), digits) + }); + } } CalculationResult::ApproximateDigitsTower(was_neg, neg, depth, exponent) => { return Some(if neg { diff --git a/factorion-lib/src/parse.rs b/factorion-lib/src/parse.rs index 168ac253..df8f795c 100644 --- a/factorion-lib/src/parse.rs +++ b/factorion-lib/src/parse.rs @@ -12,7 +12,7 @@ use crate::{ pub mod recommended { use factorion_math::rug::Integer; - pub static INTEGER_CONSTRUCTION_LIMIT: fn() -> Integer = || 10_000_000u128.into(); + pub static INTEGER_CONSTRUCTION_LIMIT: fn() -> Integer = || 200_000_000u128.into(); } const POI_STARTS: &[char] = &[ @@ -579,12 +579,19 @@ fn parse_num( *text = &text[3..]; let part = part.replace(SEPARATORS, ""); let n = part.parse::().ok()?; - return Some(Number::ApproximateDigitsTower( - false, - false, - n - 1, - 1.into(), - )); + match n.to_usize() { + Some(0) => return Some(1.into()), + Some(1) => return Some(10.into()), + Some(2) => return Some(Number::Exact(10_000_000_000u64.into())), + _ => { + return Some(Number::ApproximateDigitsTower( + false, + false, + n - 1, + 1.into(), + )); + } + } } else { // Skip ^ only (because ret None) *text = orig_text; @@ -666,6 +673,11 @@ fn parse_num( } if depth == 1 { + if top < consts.integer_construction_limit { + return Some(Number::Exact( + Integer::u64_pow_u64(10, top.to_u64().unwrap()).complete(), + )); + } return Some(Number::ApproximateDigits(false, top)); } else { return Some(Number::ApproximateDigitsTower( @@ -1846,6 +1858,17 @@ mod test { 5.into() )) ); + let num = parse_num( + &mut "10^50000000000", + false, + false, + &consts, + &NumFormat::V1(&locale::v1::NumFormat { decimal: '.' }), + ); + assert_eq!( + num, + Some(Number::ApproximateDigits(false, 50000000000u64.into())) + ); let num = parse_num( &mut "10^5!", false, @@ -1861,7 +1884,7 @@ mod test { &consts, &NumFormat::V1(&locale::v1::NumFormat { decimal: '.' }), ); - assert_eq!(num, Some(Number::ApproximateDigits(false, 5.into()))); + assert_eq!(num, Some(Number::Exact(100000.into()))); let num = parse_num( &mut "10^5", false, diff --git a/factorion-lib/tests/integration.rs b/factorion-lib/tests/integration.rs index 0300b0c2..f7341f8c 100644 --- a/factorion-lib/tests/integration.rs +++ b/factorion-lib/tests/integration.rs @@ -1544,7 +1544,7 @@ fn test_get_reply_ridiculous_number() { let reply = comment.get_reply(&consts); assert_eq!( reply, - "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of roughly 1 × 10^2652 has on the order of ^(9041)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of roughly 10^2652 has on the order of ^(9041)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ); } @@ -1566,7 +1566,7 @@ fn test_get_reply_biggest_possible_reddit() { let reply = comment.get_reply(&consts); assert_eq!( reply, - "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of roughly 9 × 10^99 has on the order of ^(20000)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of 9 × 10^99 has on the order of ^(20000)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ); } @@ -1674,7 +1674,7 @@ fn test_number_inputs() { let reply = comment.get_reply(&consts); assert_eq!( reply, - "Some of these are so large, that I can't even give the number of digits of them, so I have to make a power of ten tower.\n\nFactorial of 2 is 2 \n\nSubfactorial of 10 is 1334961 \n\nFactorial of 10 is 3628800 \n\nFactorial of 11 is 39916800 \n\nFactorial of 1000000000000 is approximately 1.403661160373756090720133867713 × 10^(11565705518103) \n\nFactorial of 10^(100) has on the order of 10^(103) digits \n\nFactorial of 10^(10\\^(100\\)) has on the order of 10^(10\\^(100\\)) digits \n\nFactorial of ^(400)10 has on the order of ^(400)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "Some of these are so large, that I can't even give the number of digits of them, so I have to make a power of ten tower.\n\nFactorial of 2 is 2 \n\nSubfactorial of 10 is 1334961 \n\nFactorial of 10 is 3628800 \n\nFactorial of 11 is 39916800 \n\nFactorial of 1000000000000 is approximately 1.403661160373756090720133867713 × 10^(11565705518103) \n\nFactorial of 10^100 is approximately 1.629404332459337373417934652984 × 10^(9.956570551809674817234887108108 × 10^101) \n\nFactorial of 10^(10\\^(100\\)) has on the order of 10^(10\\^(100\\)) digits \n\nFactorial of ^(400)10 has on the order of ^(400)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ); } @@ -1694,7 +1694,7 @@ fn test_tower_largest_int() { let reply = comment.get_reply(&consts); assert_eq!( reply, - "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of 9 × 10^(99999999) has on the order of ^(621)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!\n\nAll that of 9 × 10^99999999 has on the order of ^(621)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ) } @@ -1714,7 +1714,7 @@ fn test_tower_all() { let reply = comment.get_reply(&consts); assert_eq!( reply, - "If I posted all numbers, the comment would get too long. So I had to remove some of them.\n\nTermial of roughly 9 × 10^9999999 is approximately 4.05 × 10^(19999999) \n\nFactorial of termial of roughly 9 × 10^9999999 has approximately 8.099999665130019231123774157674 × 10^20000006 digits \n\nTermial of factorial of termial of roughly 9 × 10^9999999 has approximately 1.619999933026003846224754831535 × 10^20000007 digits \n\nFactorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(1.619999933026003846224754831535 × 10^20000007) digits \n\nTermial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(1.619999933026003846224754831535 × 10^20000007) digits \n\nFactorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of roughly 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "If I posted all numbers, the comment would get too long. So I had to remove some of them.\n\nTermial of 9 × 10^9999999 is approximately 4.05 × 10^(19999999) \n\nFactorial of termial of 9 × 10^9999999 has approximately 8.099999665130019231123774157674 × 10^20000006 digits \n\nTermial of factorial of termial of 9 × 10^9999999 has approximately 1.619999933026003846224754831535 × 10^20000007 digits \n\nFactorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(1.619999933026003846224754831535 × 10^20000007) digits \n\nTermial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(1.619999933026003846224754831535 × 10^20000007) digits \n\nFactorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nTermial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\nFactorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of factorial of termial of 9 × 10^9999999 has on the order of 10^(10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^10\\^(1.619999933026003846224754831535 × 10^20000007\\)) digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ) } @@ -1751,6 +1751,26 @@ fn test_all_that_on_multiple_calcs() { ) } +#[test] +fn test_same_in_different_writing() { + let consts = Consts::default(); + let comment = Comment::new( + "10000000000! (10^10)! (^(2)10)!", + (), + Commands::NONE, + MAX_LENGTH, + "en", + ) + .extract(&consts) + .calc(&consts); + + let reply = comment.get_reply(&consts); + assert_eq!( + reply, + "That is so large, that I can't calculate it, so I'll have to approximate.\n\nFactorial of 10000000000 is approximately 2.32579620567308336510494471995 × 10^95657055186 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + ) +} + #[test] fn test_arbitrary_comment() { let consts = Consts::default();