use core::cmp::Ordering::{self, *};
use malachite_base::num::arithmetic::traits::{Cosh, PowerOf2, Sinh, SinhCosh, SinhCoshAssign};
use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, One};
use malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};
use malachite_base::num::float::NiceFloat;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_base::rounding_modes::RoundingMode::{self, *};
use malachite_base::test_util::generators::{
primitive_float_gen, unsigned_rounding_mode_pair_gen_var_3,
};
use malachite_float::float::arithmetic::cosh::{
primitive_float_cosh, primitive_float_cosh_rational,
};
use malachite_float::float::arithmetic::sinh::{
primitive_float_sinh, primitive_float_sinh_rational,
};
use malachite_float::float::arithmetic::sinh_cosh::{
primitive_float_sinh_cosh, primitive_float_sinh_cosh_rational,
};
use malachite_float::test_util::common::{
assert_rounding_ordering_consistent, parse_hex_string, rug_round_try_from_rounding_mode,
to_hex_string,
};
use malachite_float::test_util::float::arithmetic::cosh::{
rug_cosh_prec_round, rug_cosh_rational_prec_round,
};
use malachite_float::test_util::float::arithmetic::sinh::{
rug_sinh_prec_round, rug_sinh_rational_prec_round,
};
use malachite_float::test_util::generators::{
float_gen, float_rounding_mode_pair_gen_var_47, float_unsigned_pair_gen_var_1,
float_unsigned_rounding_mode_triple_gen_var_36,
rational_unsigned_rounding_mode_triple_gen_var_10,
};
use malachite_float::{ComparableFloat, ComparableFloatRef, Float};
use malachite_q::Rational;
use malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};
use std::panic::catch_unwind;
use std::str::FromStr;
fn rug_sinh_cosh_check(
x: &Float,
prec: u64,
rm: RoundingMode,
s: &Float,
c: &Float,
o_s: Ordering,
o_c: Ordering,
) {
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let rx = rug::Float::exact_from(x);
let (rug_s, rug_o_s) = rug_sinh_prec_round(&rx, prec, rug_rm);
let (rug_c, rug_o_c) = rug_cosh_prec_round(&rx, prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_s)),
ComparableFloatRef(s)
);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(c)
);
assert_eq!(rug_o_s, o_s);
assert_eq!(rug_o_c, o_c);
}
}
#[test]
#[allow(clippy::too_many_arguments)]
fn test_sinh_cosh_prec_round() {
let test = |s,
s_hex,
prec: u64,
rm,
out_s: &str,
out_s_hex: &str,
o_out_s: Ordering,
out_c: &str,
out_c_hex: &str,
o_out_c: Ordering| {
let x = parse_hex_string(s_hex);
assert_eq!(x.to_string(), s);
let (sh, ch, o_s, o_c) = x.clone().sinh_cosh_prec_round(prec, rm);
assert!(sh.is_valid());
assert!(ch.is_valid());
assert_eq!(sh.to_string(), out_s);
assert_eq!(to_hex_string(&sh), out_s_hex);
assert_eq!(o_s, o_out_s);
assert_eq!(ch.to_string(), out_c);
assert_eq!(to_hex_string(&ch), out_c_hex);
assert_eq!(o_c, o_out_c);
let (sh_alt, ch_alt, o_s_alt, o_c_alt) = x.sinh_cosh_prec_round_ref(prec, rm);
assert_eq!(ComparableFloatRef(&sh_alt), ComparableFloatRef(&sh));
assert_eq!(ComparableFloatRef(&ch_alt), ComparableFloatRef(&ch));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
let mut sh_alt = x.clone();
let mut ch_alt = Float::NAN;
let o_alt = sh_alt.sinh_cosh_prec_round_assign(&mut ch_alt, prec, rm);
assert_eq!(ComparableFloatRef(&sh_alt), ComparableFloatRef(&sh));
assert_eq!(ComparableFloatRef(&ch_alt), ComparableFloatRef(&ch));
assert_eq!(o_alt, (o_s, o_c));
rug_sinh_cosh_check(&x, prec, rm, &sh, &ch, o_s, o_c);
};
test(
"NaN", "NaN", 1, Nearest, "NaN", "NaN", Equal, "NaN", "NaN", Equal,
);
test(
"Infinity", "Infinity", 1, Nearest, "Infinity", "Infinity", Equal, "Infinity", "Infinity",
Equal,
);
test(
"-Infinity",
"-Infinity",
1,
Nearest,
"-Infinity",
"-Infinity",
Equal,
"Infinity",
"Infinity",
Equal,
);
test(
"0.0", "0x0.0", 1, Nearest, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"-0.0", "-0x0.0", 1, Nearest, "-0.0", "-0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"0.0",
"0x0.0",
10,
Nearest,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"1.0", "0x1.0#1", 1, Floor, "1.0", "0x1.0#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"1.0", "0x1.0#1", 1, Ceiling, "2.0", "0x2.0#1", Greater, "2.0", "0x2.0#1", Greater,
);
test(
"1.0", "0x1.0#1", 1, Nearest, "1.0", "0x1.0#1", Less, "2.0", "0x2.0#1", Greater,
);
test(
"1.0",
"0x1.0#1",
10,
Floor,
"1.1738",
"0x1.2c8#10",
Less,
"1.5430",
"0x1.8b0#10",
Less,
);
test(
"1.0",
"0x1.0#1",
10,
Ceiling,
"1.1758",
"0x1.2d0#10",
Greater,
"1.5449",
"0x1.8b8#10",
Greater,
);
test(
"1.0",
"0x1.0#1",
10,
Nearest,
"1.1758",
"0x1.2d0#10",
Greater,
"1.5430",
"0x1.8b0#10",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Floor,
"1.1752011936438014568823818505953",
"0x1.2cd9fc44eb9825a80249487f0#100",
Less,
"1.5430806348152437784779056207559",
"0x1.8b07551d9f5504c2bd2810018#100",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Ceiling,
"1.1752011936438014568823818505969",
"0x1.2cd9fc44eb9825a80249487f2#100",
Greater,
"1.5430806348152437784779056207575",
"0x1.8b07551d9f5504c2bd281001a#100",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Nearest,
"1.1752011936438014568823818505953",
"0x1.2cd9fc44eb9825a80249487f0#100",
Less,
"1.5430806348152437784779056207575",
"0x1.8b07551d9f5504c2bd281001a#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Floor,
"-1.1758",
"-0x1.2d0#10",
Less,
"1.5430",
"0x1.8b0#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
10,
Ceiling,
"-1.1738",
"-0x1.2c8#10",
Greater,
"1.5449",
"0x1.8b8#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Nearest,
"-1.1758",
"-0x1.2d0#10",
Less,
"1.5430",
"0x1.8b0#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Floor,
"-1.1752011936438014568823818505969",
"-0x1.2cd9fc44eb9825a80249487f2#100",
Less,
"1.5430806348152437784779056207559",
"0x1.8b07551d9f5504c2bd2810018#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Ceiling,
"-1.1752011936438014568823818505953",
"-0x1.2cd9fc44eb9825a80249487f0#100",
Greater,
"1.5430806348152437784779056207575",
"0x1.8b07551d9f5504c2bd281001a#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Nearest,
"-1.1752011936438014568823818505953",
"-0x1.2cd9fc44eb9825a80249487f0#100",
Greater,
"1.5430806348152437784779056207575",
"0x1.8b07551d9f5504c2bd281001a#100",
Greater,
);
test(
"0.50",
"0x0.8#1",
10,
Floor,
"0.52051",
"0x0.854#10",
Less,
"1.1270",
"0x1.208#10",
Less,
);
test(
"0.50",
"0x0.8#1",
10,
Ceiling,
"0.52148",
"0x0.858#10",
Greater,
"1.1289",
"0x1.210#10",
Greater,
);
test(
"0.50",
"0x0.8#1",
10,
Nearest,
"0.52148",
"0x0.858#10",
Greater,
"1.1270",
"0x1.208#10",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Floor,
"0.52109530549374736162242562641114",
"0x0.8566807f31dcb651abc4abb0d#100",
Less,
"1.1276259652063807852262251614023",
"0x1.20ac1862ae8d0645823a4f060#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Ceiling,
"0.52109530549374736162242562641193",
"0x0.8566807f31dcb651abc4abb0e#100",
Greater,
"1.1276259652063807852262251614039",
"0x1.20ac1862ae8d0645823a4f062#100",
Greater,
);
test(
"0.50",
"0x0.8#1",
100,
Nearest,
"0.52109530549374736162242562641114",
"0x0.8566807f31dcb651abc4abb0d#100",
Less,
"1.1276259652063807852262251614023",
"0x1.20ac1862ae8d0645823a4f060#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Floor,
"0.33936",
"0x0.56e#10",
Less,
"1.0547",
"0x1.0e0#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Ceiling,
"0.33984",
"0x0.570#10",
Greater,
"1.0566",
"0x1.0e8#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Nearest,
"0.33936",
"0x0.56e#10",
Less,
"1.0566",
"0x1.0e8#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Floor,
"0.33954055725615013910126061133846",
"0x0.56ec214514ae05405cea1145d0#100",
Less,
"1.0560718678299393895268647082638",
"0x1.0e5ab9d68e232bca22825de22#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Ceiling,
"0.33954055725615013910126061133886",
"0x0.56ec214514ae05405cea1145d8#100",
Greater,
"1.0560718678299393895268647082654",
"0x1.0e5ab9d68e232bca22825de24#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Nearest,
"0.33954055725615013910126061133886",
"0x0.56ec214514ae05405cea1145d8#100",
Greater,
"1.0560718678299393895268647082638",
"0x1.0e5ab9d68e232bca22825de22#100",
Less,
);
test(
"-10.0",
"-0xa.0#4",
10,
Floor,
"-11024.0",
"-0x2.b1E+3#10",
Less,
"11008.0",
"0x2.b0E+3#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
10,
Ceiling,
"-11008.0",
"-0x2.b0E+3#10",
Greater,
"11024.0",
"0x2.b1E+3#10",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Nearest,
"-11008.0",
"-0x2.b0E+3#10",
Greater,
"11008.0",
"0x2.b0E+3#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
100,
Floor,
"-11013.232874703393377236524554847",
"-0x2b05.3b9dad3323e7c80b6e4528#100",
Less,
"11013.232920103323139721376090436",
"0x2b05.3ba0a6e25a94579ec1d08c#100",
Less,
);
test(
"-10.0",
"-0xa.0#4",
100,
Ceiling,
"-11013.232874703393377236524554834",
"-0x2b05.3b9dad3323e7c80b6e4524#100",
Greater,
"11013.232920103323139721376090449",
"0x2b05.3ba0a6e25a94579ec1d090#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Nearest,
"-11013.232874703393377236524554847",
"-0x2b05.3b9dad3323e7c80b6e4528#100",
Less,
"11013.232920103323139721376090436",
"0x2b05.3ba0a6e25a94579ec1d08c#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Floor,
"9.8398e433",
"0x3.3cE+360#10",
Less,
"9.8398e433",
"0x3.3cE+360#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Ceiling,
"9.8516e433",
"0x3.3dE+360#10",
Greater,
"9.8516e433",
"0x3.3dE+360#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Nearest,
"9.8516e433",
"0x3.3dE+360#10",
Greater,
"9.8516e433",
"0x3.3dE+360#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Floor,
"9.8503555700852349694443967612105e433",
"0x3.3ce46f35dae75b00ac567f544E+360#100",
Less,
"9.8503555700852349694443967612105e433",
"0x3.3ce46f35dae75b00ac567f544E+360#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Ceiling,
"9.8503555700852349694443967612201e433",
"0x3.3ce46f35dae75b00ac567f548E+360#100",
Greater,
"9.8503555700852349694443967612201e433",
"0x3.3ce46f35dae75b00ac567f548E+360#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Nearest,
"9.8503555700852349694443967612201e433",
"0x3.3ce46f35dae75b00ac567f548E+360#100",
Greater,
"9.8503555700852349694443967612201e433",
"0x3.3ce46f35dae75b00ac567f548E+360#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Floor,
"11.547",
"0xb.8c#10",
Less,
"11.578",
"0xb.94#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Ceiling,
"11.562",
"0xb.90#10",
Greater,
"11.594",
"0xb.98#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Nearest,
"11.547",
"0xb.8c#10",
Less,
"11.594",
"0xb.98#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Floor,
"11.548739357257748378558851329885",
"0xb.8c7a2eb97339113d35fcbd32#100",
Less,
"11.591953275521520628331101215943",
"0xb.978a3ff720008da5db54fadf#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Ceiling,
"11.548739357257748378558851329897",
"0xb.8c7a2eb97339113d35fcbd33#100",
Greater,
"11.591953275521520628331101215955",
"0xb.978a3ff720008da5db54fae0#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Nearest,
"11.548739357257748378558851329885",
"0xb.8c7a2eb97339113d35fcbd32#100",
Less,
"11.591953275521520628331101215955",
"0xb.978a3ff720008da5db54fae0#100",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Floor,
"-7.7564e43429447",
"-0x8.84E+36067375#10",
Less,
"7.7422e43429447",
"0x8.80E+36067375#10",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Ceiling,
"-7.7422e43429447",
"-0x8.80E+36067375#10",
Greater,
"7.7564e43429447",
"0x8.84E+36067375#10",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Nearest,
"-7.7564e43429447",
"-0x8.84E+36067375#10",
Less,
"7.7564e43429447",
"0x8.84E+36067375#10",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Floor,
"-7.7498837332421325220922927166788e43429447",
"-0x8.8229c7cd3e3c8988ae5d5230E+36067375#100",
Less,
"7.7498837332421325220922927166673e43429447",
"0x8.8229c7cd3e3c8988ae5d522fE+36067375#100",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Ceiling,
"-7.7498837332421325220922927166673e43429447",
"-0x8.8229c7cd3e3c8988ae5d522fE+36067375#100",
Greater,
"7.7498837332421325220922927166788e43429447",
"0x8.8229c7cd3e3c8988ae5d5230E+36067375#100",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Nearest,
"-7.7498837332421325220922927166673e43429447",
"-0x8.8229c7cd3e3c8988ae5d522fE+36067375#100",
Greater,
"7.7498837332421325220922927166673e43429447",
"0x8.8229c7cd3e3c8988ae5d522fE+36067375#100",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Floor,
"0.00097656",
"0x0.00400#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Floor,
"-0.00097847",
"-0x0.00402#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Ceiling,
"0.00097847",
"0x0.00402#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Ceiling,
"-0.00097656",
"-0x0.00400#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Nearest,
"0.00097656",
"0x0.00400#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Nearest,
"-0.00097656",
"-0x0.00400#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Down,
"0.00097656",
"0x0.00400#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Down,
"-0.00097656",
"-0x0.00400#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Up,
"0.00097847",
"0x0.00402#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Up,
"-0.00097847",
"-0x0.00402#10",
Less,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
97,
Floor,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#97",
Less,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
97,
Floor,
"-8.881784197001252323389053344839e-16",
"-0x4.000000000000000000000004E-13#97",
Less,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
97,
Ceiling,
"8.881784197001252323389053344839e-16",
"0x4.000000000000000000000004E-13#97",
Greater,
"1.000000000000000000000000000013",
"0x1.000000000000000000000001#97",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
97,
Ceiling,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#97",
Greater,
"1.000000000000000000000000000013",
"0x1.000000000000000000000001#97",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
97,
Nearest,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#97",
Less,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
97,
Nearest,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#97",
Greater,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
97,
Down,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#97",
Less,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
97,
Down,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#97",
Greater,
"1.000000000000000000000000000000",
"0x1.000000000000000000000000#97",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
97,
Up,
"8.881784197001252323389053344839e-16",
"0x4.000000000000000000000004E-13#97",
Greater,
"1.000000000000000000000000000013",
"0x1.000000000000000000000001#97",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
97,
Up,
"-8.881784197001252323389053344839e-16",
"-0x4.000000000000000000000004E-13#97",
Less,
"1.000000000000000000000000000013",
"0x1.000000000000000000000001#97",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
98,
Floor,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#98",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
98,
Floor,
"-8.881784197001252323389053344783e-16",
"-0x4.000000000000000000000002E-13#98",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
98,
Ceiling,
"8.881784197001252323389053344783e-16",
"0x4.000000000000000000000002E-13#98",
Greater,
"1.000000000000000000000000000006",
"0x1.0000000000000000000000008#98",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
98,
Ceiling,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#98",
Greater,
"1.000000000000000000000000000006",
"0x1.0000000000000000000000008#98",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
98,
Nearest,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#98",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
98,
Nearest,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#98",
Greater,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
98,
Down,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#98",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
98,
Down,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#98",
Greater,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#98",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
98,
Up,
"8.881784197001252323389053344783e-16",
"0x4.000000000000000000000002E-13#98",
Greater,
"1.000000000000000000000000000006",
"0x1.0000000000000000000000008#98",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
98,
Up,
"-8.881784197001252323389053344783e-16",
"-0x4.000000000000000000000002E-13#98",
Less,
"1.000000000000000000000000000006",
"0x1.0000000000000000000000008#98",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
99,
Floor,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#99",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
99,
Floor,
"-8.881784197001252323389053344755e-16",
"-0x4.000000000000000000000001E-13#99",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
99,
Ceiling,
"8.881784197001252323389053344755e-16",
"0x4.000000000000000000000001E-13#99",
Greater,
"1.000000000000000000000000000003",
"0x1.0000000000000000000000004#99",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
99,
Ceiling,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#99",
Greater,
"1.000000000000000000000000000003",
"0x1.0000000000000000000000004#99",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
99,
Nearest,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#99",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
99,
Nearest,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#99",
Greater,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
99,
Down,
"8.881784197001252323389053344727e-16",
"0x4.000000000000000000000000E-13#99",
Less,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
99,
Down,
"-8.881784197001252323389053344727e-16",
"-0x4.000000000000000000000000E-13#99",
Greater,
"1.000000000000000000000000000000",
"0x1.0000000000000000000000000#99",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
99,
Up,
"8.881784197001252323389053344755e-16",
"0x4.000000000000000000000001E-13#99",
Greater,
"1.000000000000000000000000000003",
"0x1.0000000000000000000000004#99",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
99,
Up,
"-8.881784197001252323389053344755e-16",
"-0x4.000000000000000000000001E-13#99",
Less,
"1.000000000000000000000000000003",
"0x1.0000000000000000000000004#99",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Floor,
"7.8886e-31",
"0x1.000E-25#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Floor,
"-7.9040e-31",
"-0x1.008E-25#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Ceiling,
"7.9040e-31",
"0x1.008E-25#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Ceiling,
"-7.8886e-31",
"-0x1.000E-25#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Nearest,
"7.8886e-31",
"0x1.000E-25#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Nearest,
"-7.8886e-31",
"-0x1.000E-25#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Down,
"7.8886e-31",
"0x1.000E-25#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Down,
"-7.8886e-31",
"-0x1.000E-25#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Up,
"7.9040e-31",
"0x1.008E-25#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Up,
"-7.9040e-31",
"-0x1.008E-25#10",
Less,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Floor,
"7.888609052210118054117285652827862296732064351090230047702790124822869216287758849295325\
8285e-31",
"0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Less,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Floor,
"-7.88860905221011805411728565282786229673206435109023004770279012482286921628775884929532\
58362e-31",
"-0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaacE-25#300",
Less,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Ceiling,
"7.888609052210118054117285652827862296732064351090230047702790124822869216287758849295325\
8362e-31",
"0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaacE-25#300",
Greater,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6900",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000002#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Ceiling,
"-7.88860905221011805411728565282786229673206435109023004770279012482286921628775884929532\
58285e-31",
"-0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Greater,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6900",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000002#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Nearest,
"7.888609052210118054117285652827862296732064351090230047702790124822869216287758849295325\
8285e-31",
"0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Less,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Nearest,
"-7.88860905221011805411728565282786229673206435109023004770279012482286921628775884929532\
58285e-31",
"-0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Greater,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Down,
"7.888609052210118054117285652827862296732064351090230047702790124822869216287758849295325\
8285e-31",
"0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Less,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Down,
"-7.88860905221011805411728565282786229673206435109023004770279012482286921628775884929532\
58285e-31",
"-0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaaaE-25#300",
Greater,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6890",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000000#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Up,
"7.888609052210118054117285652827862296732064351090230047702790124822869216287758849295325\
8362e-31",
"0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaacE-25#300",
Greater,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6900",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000002#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Up,
"-7.88860905221011805411728565282786229673206435109023004770279012482286921628775884929532\
58362e-31",
"-0x1.000000000000000000000000000000000000000000000000002aaaaaaaaaaaaaaaaaaaaaaacE-25#300",
Less,
"1.000000000000000000000000000000000000000000000000000000000000311150763893057085357203202\
6900",
"0x1.000000000000000000000000000000000000000000000000008000000000000000000000002#300",
Greater,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Floor,
"9.0949e-13",
"0x1.000E-10#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Floor,
"-9.1127e-13",
"-0x1.008E-10#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Ceiling,
"9.1127e-13",
"0x1.008E-10#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Ceiling,
"-9.0949e-13",
"-0x1.000E-10#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Nearest,
"9.0949e-13",
"0x1.000E-10#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Nearest,
"-9.0949e-13",
"-0x1.000E-10#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Down,
"9.0949e-13",
"0x1.000E-10#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Down,
"-9.0949e-13",
"-0x1.000E-10#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Up,
"9.1127e-13",
"0x1.008E-10#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Up,
"-9.1127e-13",
"-0x1.008E-10#10",
Less,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Floor,
"2.38256490488795107322e-323228497",
"0x1.0000000000000000E-268435456#64",
Less,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Floor,
"-2.38256490488795107347e-323228497",
"-0x1.0000000000000002E-268435456#64",
Less,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Ceiling,
"2.38256490488795107347e-323228497",
"0x1.0000000000000002E-268435456#64",
Greater,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Ceiling,
"-2.38256490488795107322e-323228497",
"-0x1.0000000000000000E-268435456#64",
Greater,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Nearest,
"2.38256490488795107322e-323228497",
"0x1.0000000000000000E-268435456#64",
Less,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Nearest,
"-2.38256490488795107322e-323228497",
"-0x1.0000000000000000E-268435456#64",
Greater,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Floor,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Ceiling,
"1.0758e304006137",
"0xc.54E+252471631#10",
Greater,
"1.0758e304006137",
"0xc.54E+252471631#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Nearest,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Down,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
"1.0744e304006137",
"0xc.50E+252471631#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Up,
"1.0758e304006137",
"0xc.54E+252471631#10",
Greater,
"1.0758e304006137",
"0xc.54E+252471631#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Floor,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Ceiling,
"1.0745986328169899684213985210262e304006137",
"0xc.507c7e17bca36323b1e8bc09E+252471631#100",
Greater,
"1.0745986328169899684213985210262e304006137",
"0xc.507c7e17bca36323b1e8bc09E+252471631#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Nearest,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Down,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
"1.0745986328169899684213985210251e304006137",
"0xc.507c7e17bca36323b1e8bc08E+252471631#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Up,
"1.0745986328169899684213985210262e304006137",
"0xc.507c7e17bca36323b1e8bc09E+252471631#100",
Greater,
"1.0745986328169899684213985210262e304006137",
"0xc.507c7e17bca36323b1e8bc09E+252471631#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Floor,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Ceiling,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Nearest,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Down,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Up,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Floor,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Ceiling,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Nearest,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Down,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Up,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Floor,
"-1.3321e323228496",
"-0x5.14E+268435455#10",
Less,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Ceiling,
"-1.3301e323228496",
"-0x5.12E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Nearest,
"-1.3321e323228496",
"-0x5.14E+268435455#10",
Less,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Down,
"-1.3301e323228496",
"-0x5.12E+268435455#10",
Greater,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Up,
"-1.3321e323228496",
"-0x5.14E+268435455#10",
Less,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Floor,
"-1.3315814500369112065268344141975e323228496",
"-0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Less,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Ceiling,
"-1.3315814500369112065268344141958e323228496",
"-0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Nearest,
"-1.3315814500369112065268344141975e323228496",
"-0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Less,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Down,
"-1.3315814500369112065268344141958e323228496",
"-0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Greater,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Up,
"-1.3315814500369112065268344141975e323228496",
"-0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Less,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Floor,
"1.9859e323228496",
"0x7.92E+268435455#10",
Less,
"1.9859e323228496",
"0x7.92E+268435455#10",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Ceiling,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Nearest,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Down,
"1.9859e323228496",
"0x7.92E+268435455#10",
Less,
"1.9859e323228496",
"0x7.92E+268435455#10",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Up,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
"1.9879e323228496",
"0x7.94E+268435455#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Floor,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Ceiling,
"1.9872622167931390381615986861197e323228496",
"0x7.935dcb7045691ebed3cf12140E+268435455#100",
Greater,
"1.9872622167931390381615986861197e323228496",
"0x7.935dcb7045691ebed3cf12140E+268435455#100",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Nearest,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Down,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
"1.9872622167931390381615986861180e323228496",
"0x7.935dcb7045691ebed3cf12138E+268435455#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Up,
"1.9872622167931390381615986861197e323228496",
"0x7.935dcb7045691ebed3cf12140E+268435455#100",
Greater,
"1.9872622167931390381615986861197e323228496",
"0x7.935dcb7045691ebed3cf12140E+268435455#100",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Down,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Up,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Floor,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Down,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Up,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Floor,
"-Infinity",
"-Infinity",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Ceiling,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Nearest,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Down,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Up,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Floor,
"-Infinity",
"-Infinity",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Ceiling,
"-2.0985787164673876924043581168822e323228496",
"-0x7.ffffffffffffffffffffffff8E+268435455#100",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Nearest,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Down,
"-2.0985787164673876924043581168822e323228496",
"-0x7.ffffffffffffffffffffffff8E+268435455#100",
Greater,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Up,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Down,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Up,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Floor,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Down,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Up,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Floor,
"-Infinity",
"-Infinity",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Ceiling,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Nearest,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Down,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Up,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Floor,
"-Infinity",
"-Infinity",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Ceiling,
"-2.0985787164673876924043581168822e323228496",
"-0x7.ffffffffffffffffffffffff8E+268435455#100",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Nearest,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Down,
"-2.0985787164673876924043581168822e323228496",
"-0x7.ffffffffffffffffffffffff8E+268435455#100",
Greater,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Up,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
}
#[test]
#[should_panic]
fn sinh_cosh_prec_round_fail() {
Float::ONE.sinh_cosh_prec_round(0, Nearest);
}
#[test]
#[should_panic]
fn sinh_cosh_prec_round_exact_fail() {
Float::ONE.sinh_cosh_prec_round(10, Exact);
}
#[test]
#[should_panic]
fn sinh_cosh_prec_fail() {
Float::ONE.sinh_cosh_prec(0);
}
#[test]
#[should_panic]
fn sinh_cosh_round_fail() {
Float::ONE.sinh_cosh_round(Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn sinh_cosh_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {
let (s, c, o_s, o_c) = x.clone().sinh_cosh_prec_round(prec, rm);
assert!(s.is_valid());
assert!(c.is_valid());
assert_rounding_ordering_consistent(&s, rm, o_s);
assert_rounding_ordering_consistent(&c, rm, o_c);
let (s_alt, c_alt, o_s_alt, o_c_alt) = x.sinh_cosh_prec_round_ref(prec, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
let mut s_alt = x.clone();
let mut c_alt = Float::NAN;
let o_alt = s_alt.sinh_cosh_prec_round_assign(&mut c_alt, prec, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, (o_s, o_c));
let (s_alt, o_s_alt) = x.sinh_prec_round_ref(prec, rm);
let (c_alt, o_c_alt) = x.cosh_prec_round_ref(prec, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
rug_sinh_cosh_check(&x, prec, rm, &s, &c, o_s, o_c);
if o_s == Equal && o_c == Equal {
for rm2 in [Down, Up, Floor, Ceiling, Nearest, Exact] {
let (s2, c2, o_s2, o_c2) = x.sinh_cosh_prec_round_ref(prec, rm2);
assert_eq!(ComparableFloat(s2), ComparableFloat(s.clone()));
assert_eq!(ComparableFloat(c2), ComparableFloat(c.clone()));
assert_eq!((o_s2, o_c2), (Equal, Equal));
}
} else {
assert_panic!(x.sinh_cosh_prec_round_ref(prec, Exact));
}
}
#[test]
fn sinh_cosh_prec_round_properties() {
float_unsigned_rounding_mode_triple_gen_var_36().test_properties(|(x, prec, rm)| {
sinh_cosh_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (s, c, o_s, o_c) = Float::NAN.sinh_cosh_prec_round(prec, rm);
assert!(s.is_nan());
assert!(c.is_nan());
assert_eq!((o_s, o_c), (Equal, Equal));
let (s, c, o_s, o_c) = Float::NEGATIVE_INFINITY.sinh_cosh_prec_round(prec, rm);
assert_eq!(
ComparableFloat(s),
ComparableFloat(Float::NEGATIVE_INFINITY)
);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::INFINITY));
assert_eq!((o_s, o_c), (Equal, Equal));
let (s, c, o_s, o_c) = Float::NEGATIVE_ZERO.sinh_cosh_prec_round(prec, rm);
assert_eq!(ComparableFloat(s), ComparableFloat(Float::NEGATIVE_ZERO));
assert_eq!(ComparableFloat(c), ComparableFloat(Float::one_prec(prec)));
assert_eq!((o_s, o_c), (Equal, Equal));
});
}
#[test]
fn sinh_cosh_round_properties() {
float_rounding_mode_pair_gen_var_47().test_properties(|(x, rm)| {
let (s, c, o_s, o_c) = x.clone().sinh_cosh_round(rm);
assert!(s.is_valid());
assert!(c.is_valid());
let (s_alt, c_alt, o_s_alt, o_c_alt) = x.sinh_cosh_round_ref(rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
let mut s_alt = x.clone();
let mut c_alt = Float::NAN;
let o_alt = s_alt.sinh_cosh_round_assign(&mut c_alt, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, (o_s, o_c));
let (s_alt, c_alt, o_s_alt, o_c_alt) = x.sinh_cosh_prec_round_ref(x.significant_bits(), rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
rug_sinh_cosh_check(&x, x.significant_bits(), rm, &s, &c, o_s, o_c);
});
}
#[test]
fn sinh_cosh_prec_properties() {
float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {
let (s, c, o_s, o_c) = x.clone().sinh_cosh_prec(prec);
assert!(s.is_valid());
assert!(c.is_valid());
let (s_alt, c_alt, o_s_alt, o_c_alt) = x.sinh_cosh_prec_ref(prec);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
let mut s_alt = x.clone();
let mut c_alt = Float::NAN;
let o_alt = s_alt.sinh_cosh_prec_assign(&mut c_alt, prec);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, (o_s, o_c));
let (s_alt, c_alt, o_s_alt, o_c_alt) = x.sinh_cosh_prec_round_ref(prec, Nearest);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!((o_s_alt, o_c_alt), (o_s, o_c));
});
}
#[test]
fn sinh_cosh_properties() {
float_gen().test_properties(|x| {
let (s, c) = x.clone().sinh_cosh();
assert!(s.is_valid());
assert!(c.is_valid());
let (s_alt, c_alt) = (&x).sinh_cosh();
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
let mut s_alt = x.clone();
let mut c_alt = Float::NAN;
s_alt.sinh_cosh_assign(&mut c_alt);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(ComparableFloatRef(&(&x).sinh()), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&x.cosh()), ComparableFloatRef(&c));
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_sinh_cosh() {
fn test<T: PrimitiveFloat>(x: T, out_s: T, out_c: T)
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
let (s, c) = primitive_float_sinh_cosh(x);
assert_eq!(NiceFloat(s), NiceFloat(out_s));
assert_eq!(NiceFloat(c), NiceFloat(out_c));
}
test::<f32>(f32::NAN, f32::NAN, f32::NAN);
test::<f32>(f32::INFINITY, f32::INFINITY, f32::INFINITY);
test::<f32>(
f32::NEGATIVE_INFINITY,
f32::NEGATIVE_INFINITY,
f32::INFINITY,
);
test::<f32>(0.0, 0.0, 1.0);
test::<f32>(-0.0, -0.0, 1.0);
test::<f32>(1.0, 1.1752012, 1.5430807);
test::<f32>(-1.0, -1.1752012, 1.5430807);
test::<f32>(0.5, 0.5210953, 1.127626);
test::<f32>(2.0, 3.6268604, 3.7621956);
test::<f32>(89.0, 2.2448064e38, 2.2448064e38);
test::<f32>(89.5, f32::INFINITY, f32::INFINITY);
test::<f32>(-89.5, f32::NEGATIVE_INFINITY, f32::INFINITY);
test::<f32>(1.0e-20, 1.0e-20, 1.0);
test::<f32>(1.0e-45, 1.0e-45, 1.0);
test::<f32>(3.4028235e38, f32::INFINITY, f32::INFINITY);
test::<f64>(f64::NAN, f64::NAN, f64::NAN);
test::<f64>(f64::INFINITY, f64::INFINITY, f64::INFINITY);
test::<f64>(
f64::NEGATIVE_INFINITY,
f64::NEGATIVE_INFINITY,
f64::INFINITY,
);
test::<f64>(0.0, 0.0, 1.0);
test::<f64>(-0.0, -0.0, 1.0);
test::<f64>(1.0, 1.1752011936438014, 1.5430806348152437);
test::<f64>(-1.0, -1.1752011936438014, 1.5430806348152437);
test::<f64>(0.5, 0.5210953054937474, 1.1276259652063807);
test::<f64>(2.0, 3.6268604078470186, 3.7621956910836314);
test::<f64>(709.0, 4.109203730777486e307, 4.109203730777486e307);
test::<f64>(710.0, 1.1169973830808555e308, 1.1169973830808555e308);
test::<f64>(-710.4, -1.6663642832806496e308, 1.6663642832806496e308);
test::<f64>(711.0, f64::INFINITY, f64::INFINITY);
test::<f64>(1.0e-200, 1.0e-200, 1.0);
test::<f64>(5.0e-324, 5.0e-324, 1.0);
test::<f64>(1.7976931348623157e308, f64::INFINITY, f64::INFINITY);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_sinh_cosh_properties_helper<T: PrimitiveFloat>()
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
primitive_float_gen::<T>().test_properties(|x| {
let (s, c) = primitive_float_sinh_cosh(x);
assert_eq!(NiceFloat(s), NiceFloat(primitive_float_sinh(x)));
assert_eq!(NiceFloat(c), NiceFloat(primitive_float_cosh(x)));
});
}
#[test]
fn primitive_float_sinh_cosh_properties() {
apply_fn_to_primitive_floats!(primitive_float_sinh_cosh_properties_helper);
}
#[allow(clippy::too_many_arguments)]
fn rug_sinh_cosh_rational_check(
x: &Rational,
prec: u64,
rm: RoundingMode,
s: &Float,
c: &Float,
o_s: Ordering,
o_c: Ordering,
) {
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_s, rug_o_s) = rug_sinh_rational_prec_round(x, prec, rug_rm);
let (rug_c, rug_o_c) = rug_cosh_rational_prec_round(x, prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_s)),
ComparableFloatRef(s)
);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(c)
);
assert_eq!(rug_o_s, o_s);
assert_eq!(rug_o_c, o_c);
}
}
#[test]
#[allow(clippy::too_many_arguments)]
fn test_sinh_cosh_rational_prec_round() {
let test = |s,
prec,
rm,
out_s: &str,
out_s_hex: &str,
o_out_s,
out_c: &str,
out_c_hex: &str,
o_out_c| {
let x = Rational::from_str(s).unwrap();
let (sh, ch, o_s, o_c) = Float::sinh_cosh_rational_prec_round(x.clone(), prec, rm);
assert!(sh.is_valid());
assert!(ch.is_valid());
assert_eq!(sh.to_string(), out_s);
assert_eq!(to_hex_string(&sh), out_s_hex);
assert_eq!(o_s, o_out_s);
assert_eq!(ch.to_string(), out_c);
assert_eq!(to_hex_string(&ch), out_c_hex);
assert_eq!(o_c, o_out_c);
let (sh_alt, ch_alt, o_s_alt, o_c_alt) =
Float::sinh_cosh_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&sh_alt), ComparableFloatRef(&sh));
assert_eq!(ComparableFloatRef(&ch_alt), ComparableFloatRef(&ch));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
rug_sinh_cosh_rational_check(&x, prec, rm, &sh, &ch, o_s, o_c);
};
test("0", 1, Down, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal);
test(
"0",
10,
Down,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test("0", 1, Up, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal);
test(
"0",
10,
Up,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"0", 1, Floor, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"0",
10,
Floor,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"0", 1, Ceiling, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"0",
10,
Ceiling,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"0", 1, Nearest, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"0",
10,
Nearest,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"0", 1, Exact, "0.0", "0x0.0", Equal, "1.0", "0x1.0#1", Equal,
);
test(
"0",
10,
Exact,
"0.0",
"0x0.0",
Equal,
"1.0000",
"0x1.000#10",
Equal,
);
test(
"3/5", 1, Floor, "0.50", "0x0.8#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"3/5", 1, Ceiling, "1.0", "0x1.0#1", Greater, "2.0", "0x2.0#1", Greater,
);
test(
"3/5", 1, Nearest, "0.50", "0x0.8#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"3/5",
10,
Floor,
"0.63574",
"0x0.a2c#10",
Less,
"1.1836",
"0x1.2f0#10",
Less,
);
test(
"3/5",
10,
Ceiling,
"0.63672",
"0x0.a30#10",
Greater,
"1.1855",
"0x1.2f8#10",
Greater,
);
test(
"3/5",
10,
Nearest,
"0.63672",
"0x0.a30#10",
Greater,
"1.1855",
"0x1.2f8#10",
Greater,
);
test(
"3/5",
100,
Floor,
"0.63665358214824127112345437546503",
"0x0.a2fbbaaa353beda5841b49fd2#100",
Less,
"1.1854652182422677037519132926962",
"0x1.2f7aa606e56308c3949cf77fa#100",
Less,
);
test(
"3/5",
100,
Ceiling,
"0.63665358214824127112345437546582",
"0x0.a2fbbaaa353beda5841b49fd3#100",
Greater,
"1.1854652182422677037519132926978",
"0x1.2f7aa606e56308c3949cf77fc#100",
Greater,
);
test(
"3/5",
100,
Nearest,
"0.63665358214824127112345437546503",
"0x0.a2fbbaaa353beda5841b49fd2#100",
Less,
"1.1854652182422677037519132926978",
"0x1.2f7aa606e56308c3949cf77fc#100",
Greater,
);
test(
"-3/5", 1, Floor, "-1.0", "-0x1.0#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"-3/5", 1, Ceiling, "-0.50", "-0x0.8#1", Greater, "2.0", "0x2.0#1", Greater,
);
test(
"-3/5", 1, Nearest, "-0.50", "-0x0.8#1", Greater, "1.0", "0x1.0#1", Less,
);
test(
"-3/5",
10,
Floor,
"-0.63672",
"-0x0.a30#10",
Less,
"1.1836",
"0x1.2f0#10",
Less,
);
test(
"-3/5",
10,
Ceiling,
"-0.63574",
"-0x0.a2c#10",
Greater,
"1.1855",
"0x1.2f8#10",
Greater,
);
test(
"-3/5",
10,
Nearest,
"-0.63672",
"-0x0.a30#10",
Less,
"1.1855",
"0x1.2f8#10",
Greater,
);
test(
"-3/5",
100,
Floor,
"-0.63665358214824127112345437546582",
"-0x0.a2fbbaaa353beda5841b49fd3#100",
Less,
"1.1854652182422677037519132926962",
"0x1.2f7aa606e56308c3949cf77fa#100",
Less,
);
test(
"-3/5",
100,
Ceiling,
"-0.63665358214824127112345437546503",
"-0x0.a2fbbaaa353beda5841b49fd2#100",
Greater,
"1.1854652182422677037519132926978",
"0x1.2f7aa606e56308c3949cf77fc#100",
Greater,
);
test(
"-3/5",
100,
Nearest,
"-0.63665358214824127112345437546503",
"-0x0.a2fbbaaa353beda5841b49fd2#100",
Greater,
"1.1854652182422677037519132926978",
"0x1.2f7aa606e56308c3949cf77fc#100",
Greater,
);
test(
"1/3", 1, Floor, "0.25", "0x0.4#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"1/3", 1, Ceiling, "0.50", "0x0.8#1", Greater, "2.0", "0x2.0#1", Greater,
);
test(
"1/3", 1, Nearest, "0.25", "0x0.4#1", Less, "1.0", "0x1.0#1", Less,
);
test(
"1/3",
10,
Floor,
"0.33936",
"0x0.56e#10",
Less,
"1.0547",
"0x1.0e0#10",
Less,
);
test(
"1/3",
10,
Ceiling,
"0.33984",
"0x0.570#10",
Greater,
"1.0566",
"0x1.0e8#10",
Greater,
);
test(
"1/3",
10,
Nearest,
"0.33936",
"0x0.56e#10",
Less,
"1.0566",
"0x1.0e8#10",
Greater,
);
test(
"1/3",
100,
Floor,
"0.33954055725615013910126061133846",
"0x0.56ec214514ae05405cea1145d0#100",
Less,
"1.0560718678299393895268647082638",
"0x1.0e5ab9d68e232bca22825de22#100",
Less,
);
test(
"1/3",
100,
Ceiling,
"0.33954055725615013910126061133886",
"0x0.56ec214514ae05405cea1145d8#100",
Greater,
"1.0560718678299393895268647082654",
"0x1.0e5ab9d68e232bca22825de24#100",
Greater,
);
test(
"1/3",
100,
Nearest,
"0.33954055725615013910126061133846",
"0x0.56ec214514ae05405cea1145d0#100",
Less,
"1.0560718678299393895268647082638",
"0x1.0e5ab9d68e232bca22825de22#100",
Less,
);
test(
"22/7", 1, Floor, "8.0", "0x8.0#1", Less, "8.0", "0x8.0#1", Less,
);
test(
"22/7",
1,
Ceiling,
"16.0",
"0x1.0E+1#1",
Greater,
"16.0",
"0x1.0E+1#1",
Greater,
);
test(
"22/7", 1, Nearest, "8.0", "0x8.0#1", Less, "8.0", "0x8.0#1", Less,
);
test(
"22/7",
10,
Floor,
"11.562",
"0xb.90#10",
Less,
"11.594",
"0xb.98#10",
Less,
);
test(
"22/7",
10,
Ceiling,
"11.578",
"0xb.94#10",
Greater,
"11.609",
"0xb.9c#10",
Greater,
);
test(
"22/7",
10,
Nearest,
"11.562",
"0xb.90#10",
Less,
"11.609",
"0xb.9c#10",
Greater,
);
test(
"22/7",
100,
Floor,
"11.563406494500513816416460850606",
"0xb.903b68743bd476d7129c12b8#100",
Less,
"11.606565803761966414401052945140",
"0xb.9b47e5820793d583f2840c92#100",
Less,
);
test(
"22/7",
100,
Ceiling,
"11.563406494500513816416460850618",
"0xb.903b68743bd476d7129c12b9#100",
Greater,
"11.606565803761966414401052945153",
"0xb.9b47e5820793d583f2840c93#100",
Greater,
);
test(
"22/7",
100,
Nearest,
"11.563406494500513816416460850618",
"0xb.903b68743bd476d7129c12b9#100",
Greater,
"11.606565803761966414401052945153",
"0xb.9b47e5820793d583f2840c93#100",
Greater,
);
test(
"-100",
1,
Floor,
"-2.2e43",
"-0x1.0E+36#1",
Less,
"1.1e43",
"0x8.0E+35#1",
Less,
);
test(
"-100",
1,
Ceiling,
"-1.1e43",
"-0x8.0E+35#1",
Greater,
"2.2e43",
"0x1.0E+36#1",
Greater,
);
test(
"-100",
1,
Nearest,
"-1.1e43",
"-0x8.0E+35#1",
Greater,
"1.1e43",
"0x8.0E+35#1",
Less,
);
test(
"-100",
10,
Floor,
"-1.3459e43",
"-0x9.a8E+35#10",
Less,
"1.3437e43",
"0x9.a4E+35#10",
Less,
);
test(
"-100",
10,
Ceiling,
"-1.3437e43",
"-0x9.a4E+35#10",
Greater,
"1.3459e43",
"0x9.a8E+35#10",
Greater,
);
test(
"-100",
10,
Nearest,
"-1.3437e43",
"-0x9.a4E+35#10",
Greater,
"1.3437e43",
"0x9.a4E+35#10",
Less,
);
test(
"-100",
100,
Floor,
"-1.3440585709080677242063127757915e43",
"-0x9.a4a54d8b8dfa566112849992E+35#100",
Less,
"1.3440585709080677242063127757898e43",
"0x9.a4a54d8b8dfa566112849991E+35#100",
Less,
);
test(
"-100",
100,
Ceiling,
"-1.3440585709080677242063127757898e43",
"-0x9.a4a54d8b8dfa566112849991E+35#100",
Greater,
"1.3440585709080677242063127757915e43",
"0x9.a4a54d8b8dfa566112849992E+35#100",
Greater,
);
test(
"-100",
100,
Nearest,
"-1.3440585709080677242063127757898e43",
"-0x9.a4a54d8b8dfa566112849991E+35#100",
Greater,
"1.3440585709080677242063127757898e43",
"0x9.a4a54d8b8dfa566112849991E+35#100",
Less,
);
test(
"1/1000",
1,
Floor,
"0.00098",
"0x0.004#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"1/1000",
1,
Ceiling,
"0.0020",
"0x0.008#1",
Greater,
"2.0",
"0x2.0#1",
Greater,
);
test(
"1/1000",
1,
Nearest,
"0.00098",
"0x0.004#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"1/1000",
10,
Floor,
"0.00099945",
"0x0.00418#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/1000",
10,
Ceiling,
"0.0010014",
"0x0.0041a#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1/1000",
10,
Nearest,
"0.00099945",
"0x0.00418#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/1000",
100,
Floor,
"0.0010000001666666750000001984127008",
"0x0.004189380307278af506711800d0#100",
Less,
"1.0000005000000416666680555555795",
"0x1.000008637bdc155d234906bbe#100",
Less,
);
test(
"1/1000",
100,
Ceiling,
"0.0010000001666666750000001984127023",
"0x0.004189380307278af506711800d8#100",
Greater,
"1.0000005000000416666680555555811",
"0x1.000008637bdc155d234906bc0#100",
Greater,
);
test(
"1/1000",
100,
Nearest,
"0.0010000001666666750000001984127008",
"0x0.004189380307278af506711800d0#100",
Less,
"1.0000005000000416666680555555811",
"0x1.000008637bdc155d234906bc0#100",
Greater,
);
test(
"-1/1000000",
1,
Floor,
"-1.9e-6",
"-0x0.00002#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"-1/1000000",
1,
Ceiling,
"-9.5e-7",
"-0x0.00001#1",
Greater,
"2.0",
"0x2.0#1",
Greater,
);
test(
"-1/1000000",
1,
Nearest,
"-9.5e-7",
"-0x0.00001#1",
Greater,
"1.0",
"0x1.0#1",
Less,
);
test(
"-1/1000000",
10,
Floor,
"-1.0002e-6",
"-0x0.000010c8#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-1/1000000",
10,
Ceiling,
"-9.9838e-7",
"-0x0.000010c0#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-1/1000000",
10,
Nearest,
"-1.0002e-6",
"-0x0.000010c8#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-1/1000000",
100,
Floor,
"-1.0000000000001666666666666750015e-6",
"-0x0.000010c6f7a0b5f0a04657c054111a#100",
Less,
"1.0000000000005000000000000416655",
"0x1.00000000008cbccc096f5d6de#100",
Less,
);
test(
"-1/1000000",
100,
Ceiling,
"-1.0000000000001666666666666750000e-6",
"-0x0.000010c6f7a0b5f0a04657c0541118#100",
Greater,
"1.0000000000005000000000000416670",
"0x1.00000000008cbccc096f5d6e0#100",
Greater,
);
test(
"-1/1000000",
100,
Nearest,
"-1.0000000000001666666666666750000e-6",
"-0x0.000010c6f7a0b5f0a04657c0541118#100",
Greater,
"1.0000000000005000000000000416670",
"0x1.00000000008cbccc096f5d6e0#100",
Greater,
);
test(
"1/100000000000000000000",
1,
Floor,
"6.8e-21",
"0x2.0E-17#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"1/100000000000000000000",
1,
Ceiling,
"1.4e-20",
"0x4.0E-17#1",
Greater,
"2.0",
"0x2.0#1",
Greater,
);
test(
"1/100000000000000000000",
1,
Nearest,
"6.8e-21",
"0x2.0E-17#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"1/100000000000000000000",
10,
Floor,
"9.9923e-21",
"0x2.f3E-17#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/100000000000000000000",
10,
Ceiling,
"1.0006e-20",
"0x2.f4E-17#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1/100000000000000000000",
10,
Nearest,
"1.0006e-20",
"0x2.f4E-17#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/100000000000000000000",
100,
Floor,
"9.9999999999999999999999999999955e-21",
"0x2.f394219248446baa23d2ec728E-17#100",
Less,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1/100000000000000000000",
100,
Ceiling,
"1.0000000000000000000000000000006e-20",
"0x2.f394219248446baa23d2ec72cE-17#100",
Greater,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"1/100000000000000000000",
100,
Nearest,
"9.9999999999999999999999999999955e-21",
"0x2.f394219248446baa23d2ec728E-17#100",
Less,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Floor,
"-3.2e-30",
"-0x4.0E-25#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Ceiling,
"-1.6e-30",
"-0x2.0E-25#1",
Greater,
"2.0",
"0x2.0#1",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Nearest,
"-3.2e-30",
"-0x4.0E-25#1",
Less,
"1.0",
"0x1.0#1",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Floor,
"-2.3697e-30",
"-0x3.01E-25#10",
Less,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Ceiling,
"-2.3666e-30",
"-0x3.00E-25#10",
Greater,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Nearest,
"-2.3666e-30",
"-0x3.00E-25#10",
Greater,
"1.0000",
"0x1.000#10",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Floor,
"-2.3665827156630354162351856958508e-30",
"-0x3.0000000000000000000000004E-25#100",
Less,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Ceiling,
"-2.3665827156630354162351856958484e-30",
"-0x3.0000000000000000000000000E-25#100",
Greater,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Nearest,
"-2.3665827156630354162351856958484e-30",
"-0x3.0000000000000000000000000E-25#100",
Greater,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1488522235/2",
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"1488522235/2",
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"1488522235/2",
1,
Nearest,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"1488522235/2",
10,
Floor,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
"1.3301e323228496",
"0x5.12E+268435455#10",
Less,
);
test(
"1488522235/2",
10,
Ceiling,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"1488522235/2",
10,
Nearest,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
"1.3321e323228496",
"0x5.14E+268435455#10",
Greater,
);
test(
"1488522235/2",
100,
Floor,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
"1.3315814500369112065268344141958e323228496",
"0x5.137d0b40cdfb4457d4a570f10E+268435455#100",
Less,
);
test(
"1488522235/2",
100,
Ceiling,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"1488522235/2",
100,
Nearest,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
"1.3315814500369112065268344141975e323228496",
"0x5.137d0b40cdfb4457d4a570f18E+268435455#100",
Greater,
);
test(
"7442611177/10",
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"7442611177/10",
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"7442611177/10",
1,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"7442611177/10",
10,
Floor,
"1.6252e323228496",
"0x6.32E+268435455#10",
Less,
"1.6252e323228496",
"0x6.32E+268435455#10",
Less,
);
test(
"7442611177/10",
10,
Ceiling,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
);
test(
"7442611177/10",
10,
Nearest,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
);
test(
"7442611177/10",
100,
Floor,
"1.6263972557900017291577754485045e323228496",
"0x6.3332e349c3b727aba6fa728b0E+268435455#100",
Less,
"1.6263972557900017291577754485045e323228496",
"0x6.3332e349c3b727aba6fa728b0E+268435455#100",
Less,
);
test(
"7442611177/10",
100,
Ceiling,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
);
test(
"7442611177/10",
100,
Nearest,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
);
test(
"-7442611177/10",
1,
Floor,
"-Infinity",
"-Infinity",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"-7442611177/10",
1,
Ceiling,
"-1.0e323228496",
"-0x4.0E+268435455#1",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"-7442611177/10",
1,
Nearest,
"-Infinity",
"-Infinity",
Less,
"Infinity",
"Infinity",
Greater,
);
test(
"-7442611177/10",
10,
Floor,
"-1.6272e323228496",
"-0x6.34E+268435455#10",
Less,
"1.6252e323228496",
"0x6.32E+268435455#10",
Less,
);
test(
"-7442611177/10",
10,
Ceiling,
"-1.6252e323228496",
"-0x6.32E+268435455#10",
Greater,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
);
test(
"-7442611177/10",
10,
Nearest,
"-1.6272e323228496",
"-0x6.34E+268435455#10",
Less,
"1.6272e323228496",
"0x6.34E+268435455#10",
Greater,
);
test(
"-7442611177/10",
100,
Floor,
"-1.6263972557900017291577754485062e323228496",
"-0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Less,
"1.6263972557900017291577754485045e323228496",
"0x6.3332e349c3b727aba6fa728b0E+268435455#100",
Less,
);
test(
"-7442611177/10",
100,
Ceiling,
"-1.6263972557900017291577754485045e323228496",
"-0x6.3332e349c3b727aba6fa728b0E+268435455#100",
Greater,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
);
test(
"-7442611177/10",
100,
Nearest,
"-1.6263972557900017291577754485062e323228496",
"-0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Less,
"1.6263972557900017291577754485062e323228496",
"0x6.3332e349c3b727aba6fa728b8E+268435455#100",
Greater,
);
test(
"744261118",
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"744261118",
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118",
1,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118",
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"744261118",
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118",
10,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118",
100,
Floor,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"744261118",
100,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"744261118",
100,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test(
"10000000000",
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
1,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"10000000000",
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
10,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
100,
Floor,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
"2.0985787164673876924043581168822e323228496",
"0x7.ffffffffffffffffffffffff8E+268435455#100",
Less,
);
test(
"10000000000",
100,
Ceiling,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"10000000000",
100,
Nearest,
"Infinity",
"Infinity",
Greater,
"Infinity",
"Infinity",
Greater,
);
test(
"1/1000",
100,
Down,
"0.0010000001666666750000001984127008",
"0x0.004189380307278af506711800d0#100",
Less,
"1.0000005000000416666680555555795",
"0x1.000008637bdc155d234906bbe#100",
Less,
);
test(
"-3/5",
100,
Down,
"-0.63665358214824127112345437546503",
"-0x0.a2fbbaaa353beda5841b49fd2#100",
Greater,
"1.1854652182422677037519132926962",
"0x1.2f7aa606e56308c3949cf77fa#100",
Less,
);
test(
"1/1000",
100,
Up,
"0.0010000001666666750000001984127023",
"0x0.004189380307278af506711800d8#100",
Greater,
"1.0000005000000416666680555555811",
"0x1.000008637bdc155d234906bc0#100",
Greater,
);
test(
"-3/5",
100,
Up,
"-0.63665358214824127112345437546582",
"-0x0.a2fbbaaa353beda5841b49fd3#100",
Less,
"1.1854652182422677037519132926978",
"0x1.2f7aa606e56308c3949cf77fc#100",
Greater,
);
}
#[test]
fn test_sinh_cosh_rational_extreme() {
let x = Rational::power_of_2(-(1i64 << 30) - 10);
let (s, c, o_s, o_c) = Float::sinh_cosh_rational_prec_round_ref(&x, 10, Ceiling);
assert_eq!(
ComparableFloat(s),
ComparableFloat(Float::min_positive_value_prec(10))
);
assert_eq!(c.to_string(), "1.0020");
assert_eq!((o_s, o_c), (Greater, Greater));
let (s, c, o_s, o_c) = Float::sinh_cosh_rational_prec_round(-x, 10, Nearest);
assert_eq!(ComparableFloat(s), ComparableFloat(Float::NEGATIVE_ZERO));
assert_eq!(c.to_string(), "1.0000");
assert_eq!((o_s, o_c), (Greater, Less));
let x = Rational::power_of_2(1i64 << 30);
let (s, c, o_s, o_c) = Float::sinh_cosh_rational_prec_round(-x, 10, Floor);
assert_eq!(
ComparableFloat(s),
ComparableFloat(Float::NEGATIVE_INFINITY)
);
assert_eq!(
ComparableFloat(c),
ComparableFloat(Float::max_finite_value_with_prec(10))
);
assert_eq!((o_s, o_c), (Less, Less));
}
#[test]
#[should_panic]
fn sinh_cosh_rational_prec_fail() {
Float::sinh_cosh_rational_prec(Rational::ONE, 0);
}
#[test]
#[should_panic]
fn sinh_cosh_rational_prec_ref_fail() {
Float::sinh_cosh_rational_prec_ref(&Rational::ONE, 0);
}
#[test]
#[should_panic]
fn sinh_cosh_rational_prec_round_fail_1() {
Float::sinh_cosh_rational_prec_round(Rational::ONE, 0, Floor);
}
#[test]
#[should_panic]
fn sinh_cosh_rational_prec_round_fail_2() {
Float::sinh_cosh_rational_prec_round(Rational::ONE, 10, Exact);
}
#[test]
#[should_panic]
fn sinh_cosh_rational_prec_round_ref_fail() {
Float::sinh_cosh_rational_prec_round_ref(&Rational::ONE, 10, Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn sinh_cosh_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {
let (s, c, o_s, o_c) = Float::sinh_cosh_rational_prec_round(x.clone(), prec, rm);
assert!(s.is_valid());
assert!(c.is_valid());
assert_rounding_ordering_consistent(&s, rm, o_s);
assert_rounding_ordering_consistent(&c, rm, o_c);
let (s_alt, c_alt, o_s_alt, o_c_alt) = Float::sinh_cosh_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
let (s_alt, o_s_alt) = Float::sinh_rational_prec_round_ref(&x, prec, rm);
let (c_alt, o_c_alt) = Float::cosh_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
rug_sinh_cosh_rational_check(&x, prec, rm, &s, &c, o_s, o_c);
if o_s == Equal && o_c == Equal {
for rm2 in [Down, Up, Floor, Ceiling, Nearest, Exact] {
let (s2, c2, o_s2, o_c2) = Float::sinh_cosh_rational_prec_round_ref(&x, prec, rm2);
assert_eq!(ComparableFloat(s2), ComparableFloat(s.clone()));
assert_eq!(ComparableFloat(c2), ComparableFloat(c.clone()));
assert_eq!((o_s2, o_c2), (Equal, Equal));
}
} else {
assert_panic!(Float::sinh_cosh_rational_prec_round_ref(&x, prec, Exact));
}
}
#[test]
fn sinh_cosh_rational_prec_round_properties() {
rational_unsigned_rounding_mode_triple_gen_var_10().test_properties(|(x, prec, rm)| {
sinh_cosh_rational_prec_round_properties_helper(x, prec, rm);
});
}
#[test]
fn sinh_cosh_rational_prec_properties() {
rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {
let (s, c, o_s, o_c) = Float::sinh_cosh_rational_prec(x.clone(), prec);
assert!(s.is_valid());
assert!(c.is_valid());
let (s_alt, c_alt, o_s_alt, o_c_alt) = Float::sinh_cosh_rational_prec_ref(&x, prec);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
let (s_alt, c_alt, o_s_alt, o_c_alt) =
Float::sinh_cosh_rational_prec_round_ref(&x, prec, Nearest);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
if let Ok(f) = Float::try_from(&x) {
let (s_alt, c_alt, o_s_alt, o_c_alt) = f.sinh_cosh_prec(prec);
assert_eq!(ComparableFloatRef(&s_alt), ComparableFloatRef(&s));
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_s_alt, o_s);
assert_eq!(o_c_alt, o_c);
}
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_sinh_cosh_rational() {
fn test<T: PrimitiveFloat>(s: &str, out_s: T, out_c: T)
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
let x = Rational::from_str(s).unwrap();
let (sh, ch) = primitive_float_sinh_cosh_rational::<T>(&x);
assert_eq!(NiceFloat(sh), NiceFloat(out_s));
assert_eq!(NiceFloat(ch), NiceFloat(out_c));
}
test::<f32>("0", 0.0, 1.0);
test::<f32>("1", 1.1752012, 1.5430807);
test::<f32>("-1", -1.1752012, 1.5430807);
test::<f32>("1/3", 0.33954057, 1.0560719);
test::<f32>("22/7", 11.563407, 11.606565);
test::<f32>("-90", f32::NEGATIVE_INFINITY, f32::INFINITY);
test::<f32>("710", f32::INFINITY, f32::INFINITY);
test::<f32>("-711", f32::NEGATIVE_INFINITY, f32::INFINITY);
test::<f32>("1/100000000000000000000", 1.0e-20, 1.0);
test::<f32>("1/10000000000000000000000000000000000000000", 1.0e-40, 1.0);
test::<f32>(
"-1/100000000000000000000000000000000000000000000000000",
-0.0,
1.0,
);
test::<f64>("0", 0.0, 1.0);
test::<f64>("1", 1.1752011936438014, 1.5430806348152437);
test::<f64>("-1", -1.1752011936438014, 1.5430806348152437);
test::<f64>("1/3", 0.3395405572561501, 1.0560718678299394);
test::<f64>("22/7", 11.563406494500514, 11.606565803761967);
test::<f64>("-90", -6.102016471589204e38, 6.102016471589204e38);
test::<f64>("710", 1.1169973830808555e308, 1.1169973830808555e308);
test::<f64>("-711", f64::NEGATIVE_INFINITY, f64::INFINITY);
test::<f64>("1/100000000000000000000", 1.0e-20, 1.0);
test::<f64>("1/10000000000000000000000000000000000000000", 1.0e-40, 1.0);
test::<f64>(
"-1/100000000000000000000000000000000000000000000000000",
-1.0e-50,
1.0,
);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_sinh_cosh_rational_properties_helper<T: PrimitiveFloat>()
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
rational_gen().test_properties(|x| {
let (s, c) = primitive_float_sinh_cosh_rational::<T>(&x);
assert_eq!(
NiceFloat(s),
NiceFloat(primitive_float_sinh_rational::<T>(&x))
);
assert_eq!(
NiceFloat(c),
NiceFloat(primitive_float_cosh_rational::<T>(&x))
);
});
}
#[test]
fn primitive_float_sinh_cosh_rational_properties() {
apply_fn_to_primitive_floats!(primitive_float_sinh_cosh_rational_properties_helper);
}