diff --git a/Cargo.lock b/Cargo.lock index cf573d3..bacc351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "factorion-bot-discord" -version = "2.5.0" +version = "2.5.1" dependencies = [ "anyhow", "dotenvy", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "factorion-bot-reddit" -version = "5.6.0" +version = "5.6.1" dependencies = [ "anyhow", "base64 0.22.1", @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "factorion-lib" -version = "5.0.0" +version = "5.0.1" dependencies = [ "arbtest", "chrono", diff --git a/factorion-bot-discord/Cargo.toml b/factorion-bot-discord/Cargo.toml index 960c09c..194f4c4 100644 --- a/factorion-bot-discord/Cargo.toml +++ b/factorion-bot-discord/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-discord" -version = "2.5.0" +version = "2.5.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 = "5.0.0", features = ["serde", "influxdb"] } +factorion-lib = { path = "../factorion-lib", version = "5.0.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 2cec897..c058176 100644 --- a/factorion-bot-reddit/Cargo.toml +++ b/factorion-bot-reddit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-reddit" -version = "5.6.0" +version = "5.6.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 = "5.0.0", features = ["serde", "influxdb"]} +factorion-lib = {path = "../factorion-lib", version = "5.0.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 e2d44df..f8a61c4 100644 --- a/factorion-lib/Cargo.toml +++ b/factorion-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-lib" -version = "5.0.0" +version = "5.0.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 183e152..08bd5d1 100644 --- a/factorion-lib/src/calculation_results.rs +++ b/factorion-lib/src/calculation_results.rs @@ -6,6 +6,8 @@ use crate::format::{ use crate::impl_all_bitwise; use crate::impl_bitwise; use factorion_math::length; +use factorion_math::rug::Complete; +use factorion_math::rug::integer::IntegerExt64; #[cfg(any(feature = "serde", test))] use serde::{Deserialize, Serialize}; use std::ops::BitAnd; diff --git a/factorion-lib/src/calculation_tasks.rs b/factorion-lib/src/calculation_tasks.rs index b433a0c..354328c 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/format.rs b/factorion-lib/src/format.rs index 3570331..4260f7d 100644 --- a/factorion-lib/src/format.rs +++ b/factorion-lib/src/format.rs @@ -1,6 +1,6 @@ //! This module holds the underlying formatting functions used in [`calculation_result`] use crate::{Consts, locale}; -use factorion_math::rug::{Float, Integer, ops::Pow}; +use factorion_math::rug::{Complete, Float, Integer, integer::IntegerExt64, ops::Pow}; use std::{borrow::Cow, fmt::Write}; const SINGLES: [&str; 10] = [ @@ -293,11 +293,16 @@ pub 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); @@ -319,7 +324,11 @@ pub 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) } @@ -530,23 +539,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/parse.rs b/factorion-lib/src/parse.rs index 168ac25..df8f795 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 5eddbb5..2981661 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_command_write_out() { let consts = Consts::default();