use core::cmp::Ordering::{self, *};
use malachite_base::num::arithmetic::traits::{Csch, CschAssign, PowerOf2};
use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::basic::traits::{
Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,
};
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::rounding_modes::exhaustive::exhaustive_rounding_modes;
use malachite_base::test_util::generators::{
primitive_float_gen, unsigned_rounding_mode_pair_gen_var_3,
};
use malachite_float::float::arithmetic::csch::{
primitive_float_csch, primitive_float_csch_rational,
};
use malachite_float::test_util::common::{
assert_rounding_ordering_consistent, parse_hex_string, round_once_to_primitive,
rug_round_try_from_rounding_mode, to_hex_string,
};
use malachite_float::test_util::float::arithmetic::csch::{
rug_csch, rug_csch_prec, rug_csch_prec_round, rug_csch_rational_prec,
rug_csch_rational_prec_round, rug_csch_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;
#[test]
fn test_csch_prec_round() {
let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {
let x = parse_hex_string(s_hex);
assert_eq!(x.to_string(), s);
let (c, o) = x.clone().csch_prec_round(prec, rm);
assert!(c.is_valid());
assert_eq!(c.to_string(), out);
assert_eq!(to_hex_string(&c), out_hex);
assert_eq!(o, o_out);
let (c_alt, o_alt) = x.csch_prec_round_ref(prec, rm);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let mut c_alt = x.clone();
let o_alt = c_alt.csch_prec_round_assign(prec, rm);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_c, rug_o) = rug_csch_prec_round(&rug::Float::exact_from(&x), prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
};
test("NaN", "NaN", 1, Nearest, "NaN", "NaN", Equal);
test("Infinity", "Infinity", 1, Nearest, "0.0", "0x0.0", Equal);
test(
"-Infinity",
"-Infinity",
1,
Nearest,
"-0.0",
"-0x0.0",
Equal,
);
test("0.0", "0x0.0", 1, Nearest, "Infinity", "Infinity", Equal);
test(
"-0.0",
"-0x0.0",
1,
Nearest,
"-Infinity",
"-Infinity",
Equal,
);
test("0.0", "0x0.0", 10, Nearest, "Infinity", "Infinity", Equal);
test("1.0", "0x1.0#1", 1, Floor, "0.50", "0x0.8#1", Less);
test("1.0", "0x1.0#1", 1, Ceiling, "1.0", "0x1.0#1", Greater);
test("1.0", "0x1.0#1", 1, Nearest, "1.0", "0x1.0#1", Greater);
test("1.0", "0x1.0#1", 10, Floor, "0.85059", "0x0.d9c#10", Less);
test(
"1.0",
"0x1.0#1",
10,
Ceiling,
"0.85156",
"0x0.da0#10",
Greater,
);
test("1.0", "0x1.0#1", 10, Nearest, "0.85059", "0x0.d9c#10", Less);
test(
"1.0",
"0x1.0#1",
100,
Floor,
"0.85091812823932154513384276328642",
"0x0.d9d5c53c5c86070b36fe901df#100",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Ceiling,
"0.85091812823932154513384276328721",
"0x0.d9d5c53c5c86070b36fe901e0#100",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Nearest,
"0.85091812823932154513384276328721",
"0x0.d9d5c53c5c86070b36fe901e0#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Floor,
"-0.85156",
"-0x0.da0#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
10,
Ceiling,
"-0.85059",
"-0x0.d9c#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Nearest,
"-0.85059",
"-0x0.d9c#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Down,
"-0.85059",
"-0x0.d9c#10",
Greater,
);
test("-1.0", "-0x1.0#1", 10, Up, "-0.85156", "-0x0.da0#10", Less);
test(
"-1.0",
"-0x1.0#1",
100,
Floor,
"-0.85091812823932154513384276328721",
"-0x0.d9d5c53c5c86070b36fe901e0#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Ceiling,
"-0.85091812823932154513384276328642",
"-0x0.d9d5c53c5c86070b36fe901df#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Nearest,
"-0.85091812823932154513384276328721",
"-0x0.d9d5c53c5c86070b36fe901e0#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Down,
"-0.85091812823932154513384276328642",
"-0x0.d9d5c53c5c86070b36fe901df#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Up,
"-0.85091812823932154513384276328721",
"-0x0.d9d5c53c5c86070b36fe901e0#100",
Less,
);
test("0.50", "0x0.8#1", 10, Floor, "1.9180", "0x1.eb0#10", Less);
test(
"0.50",
"0x0.8#1",
10,
Ceiling,
"1.9199",
"0x1.eb8#10",
Greater,
);
test(
"0.50",
"0x0.8#1",
10,
Nearest,
"1.9199",
"0x1.eb8#10",
Greater,
);
test("0.50", "0x0.8#1", 10, Down, "1.9180", "0x1.eb0#10", Less);
test("0.50", "0x0.8#1", 10, Up, "1.9199", "0x1.eb8#10", Greater);
test(
"0.50",
"0x0.8#1",
100,
Floor,
"1.9190347513349437194922028787267",
"0x1.eb45dc88defecfc84d1dc4fd0#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Ceiling,
"1.9190347513349437194922028787282",
"0x1.eb45dc88defecfc84d1dc4fd2#100",
Greater,
);
test(
"0.50",
"0x0.8#1",
100,
Nearest,
"1.9190347513349437194922028787267",
"0x1.eb45dc88defecfc84d1dc4fd0#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Down,
"1.9190347513349437194922028787267",
"0x1.eb45dc88defecfc84d1dc4fd0#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Up,
"1.9190347513349437194922028787282",
"0x1.eb45dc88defecfc84d1dc4fd2#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Floor,
"2.9414",
"0x2.f1#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Ceiling,
"2.9453",
"0x2.f2#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Nearest,
"2.9453",
"0x2.f2#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Down,
"2.9414",
"0x2.f1#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Up,
"2.9453",
"0x2.f2#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Floor,
"2.9451562666948143476455860034919",
"0x2.f1f5c2d7104d708fac22e7c68#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Ceiling,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Nearest,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Down,
"2.9451562666948143476455860034919",
"0x2.f1f5c2d7104d708fac22e7c68#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Up,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Greater,
);
test("2.0", "0x2.0#2", 10, Floor, "0.27539", "0x0.468#10", Less);
test(
"2.0",
"0x2.0#2",
10,
Ceiling,
"0.27588",
"0x0.46a#10",
Greater,
);
test(
"2.0",
"0x2.0#2",
10,
Nearest,
"0.27588",
"0x0.46a#10",
Greater,
);
test("2.0", "0x2.0#2", 10, Down, "0.27539", "0x0.468#10", Less);
test("2.0", "0x2.0#2", 10, Up, "0.27588", "0x0.46a#10", Greater);
test(
"2.0",
"0x2.0#2",
100,
Floor,
"0.27572056477178320775835148216293",
"0x0.46959f78878a98f9a7d213a2d8#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Ceiling,
"0.27572056477178320775835148216332",
"0x0.46959f78878a98f9a7d213a2e0#100",
Greater,
);
test(
"2.0",
"0x2.0#2",
100,
Nearest,
"0.27572056477178320775835148216293",
"0x0.46959f78878a98f9a7d213a2d8#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Down,
"0.27572056477178320775835148216293",
"0x0.46959f78878a98f9a7d213a2d8#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Up,
"0.27572056477178320775835148216332",
"0x0.46959f78878a98f9a7d213a2e0#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Floor,
"-0.000090837",
"-0x0.0005f4#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
10,
Ceiling,
"-0.000090718",
"-0x0.0005f2#10",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Nearest,
"-0.000090837",
"-0x0.0005f4#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
10,
Down,
"-0.000090718",
"-0x0.0005f2#10",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Up,
"-0.000090837",
"-0x0.0005f4#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
100,
Floor,
"-0.000090799859712122162833736493607358",
"-0x0.0005f35e6d8dcce82e421fdc56470#100",
Less,
);
test(
"-10.0",
"-0xa.0#4",
100,
Ceiling,
"-0.000090799859712122162833736493607262",
"-0x0.0005f35e6d8dcce82e421fdc56468#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Nearest,
"-0.000090799859712122162833736493607262",
"-0x0.0005f35e6d8dcce82e421fdc56468#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Down,
"-0.000090799859712122162833736493607262",
"-0x0.0005f35e6d8dcce82e421fdc56468#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Up,
"-0.000090799859712122162833736493607358",
"-0x0.0005f35e6d8dcce82e421fdc56470#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Floor,
"0.086548",
"0x0.1628#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Ceiling,
"0.086670",
"0x0.1630#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Nearest,
"0.086548",
"0x0.1628#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Down,
"0.086548",
"0x0.1628#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Up,
"0.086670",
"0x0.1630#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Floor,
"0.086589537530046941824099701714064",
"0x0.162abb5fde086fc5c9e34a86f4#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Ceiling,
"0.086589537530046941824099701714162",
"0x0.162abb5fde086fc5c9e34a86f6#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Nearest,
"0.086589537530046941824099701714162",
"0x0.162abb5fde086fc5c9e34a86f6#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Down,
"0.086589537530046941824099701714064",
"0x0.162abb5fde086fc5c9e34a86f4#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Up,
"0.086589537530046941824099701714162",
"0x0.162abb5fde086fc5c9e34a86f6#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Floor,
"1.0144e-434",
"0x4.f0E-361#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Ceiling,
"1.0160e-434",
"0x4.f2E-361#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Nearest,
"1.0160e-434",
"0x4.f2E-361#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Down,
"1.0144e-434",
"0x4.f0E-361#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Up,
"1.0160e-434",
"0x4.f2E-361#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Floor,
"1.0151917795098913530583618959146e-434",
"0x4.f1086790625503cc93d1b9e50E-361#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Ceiling,
"1.0151917795098913530583618959159e-434",
"0x4.f1086790625503cc93d1b9e58E-361#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Nearest,
"1.0151917795098913530583618959146e-434",
"0x4.f1086790625503cc93d1b9e50E-361#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Down,
"1.0151917795098913530583618959146e-434",
"0x4.f1086790625503cc93d1b9e50E-361#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Up,
"1.0151917795098913530583618959159e-434",
"0x4.f1086790625503cc93d1b9e58E-361#100",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Floor,
"6.5911e-434295",
"0x3.e3E-360674#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Ceiling,
"6.5977e-434295",
"0x3.e4E-360674#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Nearest,
"6.5911e-434295",
"0x3.e3E-360674#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Down,
"6.5911e-434295",
"0x3.e3E-360674#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Up,
"6.5977e-434295",
"0x3.e4E-360674#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Floor,
"6.5936629561771171579378159382151e-434295",
"0x3.e362986bdaa297eea886313f4E-360674#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Ceiling,
"6.5936629561771171579378159382204e-434295",
"0x3.e362986bdaa297eea886313f8E-360674#100",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Nearest,
"6.5936629561771171579378159382151e-434295",
"0x3.e362986bdaa297eea886313f4E-360674#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Down,
"6.5936629561771171579378159382151e-434295",
"0x3.e362986bdaa297eea886313f4E-360674#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Up,
"6.5936629561771171579378159382204e-434295",
"0x3.e362986bdaa297eea886313f8E-360674#100",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Floor,
"5.3094e-233160075",
"0x6.52E-193635251#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Ceiling,
"5.3159e-233160075",
"0x6.54E-193635251#10",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Nearest,
"5.3094e-233160075",
"0x6.52E-193635251#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Down,
"5.3094e-233160075",
"0x6.52E-193635251#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Up,
"5.3159e-233160075",
"0x6.54E-193635251#10",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Floor,
"5.3096230646839805874289616336017e-233160075",
"0x6.5213d1f51096f677b1bdae508E-193635251#100",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Ceiling,
"5.3096230646839805874289616336070e-233160075",
"0x6.5213d1f51096f677b1bdae510E-193635251#100",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Nearest,
"5.3096230646839805874289616336070e-233160075",
"0x6.5213d1f51096f677b1bdae510E-193635251#100",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Down,
"5.3096230646839805874289616336017e-233160075",
"0x6.5213d1f51096f677b1bdae508E-193635251#100",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Up,
"5.3096230646839805874289616336070e-233160075",
"0x6.5213d1f51096f677b1bdae510E-193635251#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Floor,
"9.3025e-304006138",
"0x1.4c8E-252471632#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Ceiling,
"9.3165e-304006138",
"0x1.4d0E-252471632#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Nearest,
"9.3025e-304006138",
"0x1.4c8E-252471632#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Down,
"9.3025e-304006138",
"0x1.4c8E-252471632#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Up,
"9.3165e-304006138",
"0x1.4d0E-252471632#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Floor,
"9.3058000397652234489131203297804e-304006138",
"0x1.4c9e6550bdb38bcdec64deb32E-252471632#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Ceiling,
"9.3058000397652234489131203297917e-304006138",
"0x1.4c9e6550bdb38bcdec64deb34E-252471632#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Nearest,
"9.3058000397652234489131203297917e-304006138",
"0x1.4c9e6550bdb38bcdec64deb34E-252471632#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Down,
"9.3058000397652234489131203297804e-304006138",
"0x1.4c9e6550bdb38bcdec64deb32E-252471632#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Up,
"9.3058000397652234489131203297917e-304006138",
"0x1.4c9e6550bdb38bcdec64deb34E-252471632#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Floor,
"7.5014e-323228497",
"0x3.26E-268435456#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Ceiling,
"7.5107e-323228497",
"0x3.27E-268435456#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Nearest,
"7.5107e-323228497",
"0x3.27E-268435456#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Down,
"7.5014e-323228497",
"0x3.26E-268435456#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Up,
"7.5107e-323228497",
"0x3.27E-268435456#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Floor,
"7.5098673083218467310380527281516e-323228497",
"0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Ceiling,
"7.5098673083218467310380527281592e-323228497",
"0x3.26ea18e02da8f8a2632086efcE-268435456#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Nearest,
"7.5098673083218467310380527281516e-323228497",
"0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Down,
"7.5098673083218467310380527281516e-323228497",
"0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Up,
"7.5098673083218467310380527281592e-323228497",
"0x3.26ea18e02da8f8a2632086efcE-268435456#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Floor,
"-7.5107e-323228497",
"-0x3.27E-268435456#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Ceiling,
"-7.5014e-323228497",
"-0x3.26E-268435456#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Nearest,
"-7.5107e-323228497",
"-0x3.27E-268435456#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Down,
"-7.5014e-323228497",
"-0x3.26E-268435456#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Up,
"-7.5107e-323228497",
"-0x3.27E-268435456#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Floor,
"-7.5098673083218467310380527281592e-323228497",
"-0x3.26ea18e02da8f8a2632086efcE-268435456#100",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Ceiling,
"-7.5098673083218467310380527281516e-323228497",
"-0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Nearest,
"-7.5098673083218467310380527281516e-323228497",
"-0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Down,
"-7.5098673083218467310380527281516e-323228497",
"-0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Up,
"-7.5098673083218467310380527281592e-323228497",
"-0x3.26ea18e02da8f8a2632086efcE-268435456#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Floor,
"2.7595e-323228497",
"0x1.288E-268435456#10",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Ceiling,
"2.7641e-323228497",
"0x1.290E-268435456#10",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Nearest,
"2.7641e-323228497",
"0x1.290E-268435456#10",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Down,
"2.7595e-323228497",
"0x1.288E-268435456#10",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Up,
"2.7641e-323228497",
"0x1.290E-268435456#10",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Floor,
"2.7627257886571247097149806987996e-323228497",
"0x1.28d8e45434c7216121ffbfc56E-268435456#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Ceiling,
"2.7627257886571247097149806988033e-323228497",
"0x1.28d8e45434c7216121ffbfc58E-268435456#100",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Nearest,
"2.7627257886571247097149806988033e-323228497",
"0x1.28d8e45434c7216121ffbfc58E-268435456#100",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Down,
"2.7627257886571247097149806987996e-323228497",
"0x1.28d8e45434c7216121ffbfc56E-268435456#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Up,
"2.7627257886571247097149806988033e-323228497",
"0x1.28d8e45434c7216121ffbfc58E-268435456#100",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Nearest,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Nearest,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Nearest,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Nearest,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Floor,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Ceiling,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Nearest,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Down,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Up,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Floor,
"-2.3825649048879510732161697817327e-323228497",
"-0x1.0000000000000000000000000E-268435456#100",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Ceiling,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Nearest,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Down,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Up,
"-2.3825649048879510732161697817327e-323228497",
"-0x1.0000000000000000000000000E-268435456#100",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Floor,
"1023.0",
"0x3ff.0#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Floor,
"-1024.0",
"-0x400.0#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Ceiling,
"1024.0",
"0x400.0#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Ceiling,
"-1023.0",
"-0x3ff.0#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Nearest,
"1024.0",
"0x400.0#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Nearest,
"-1024.0",
"-0x400.0#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Down,
"1023.0",
"0x3ff.0#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Down,
"-1023.0",
"-0x3ff.0#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Up,
"1024.0",
"0x400.0#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Up,
"-1024.0",
"-0x400.0#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Floor,
"1023.9998372396014423815743004207",
"0x3ff.fff55555693e93c7a725540#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Floor,
"-1023.9998372396014423815743004215",
"-0x3ff.fff55555693e93c7a725544#100",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Ceiling,
"1023.9998372396014423815743004215",
"0x3ff.fff55555693e93c7a725544#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Ceiling,
"-1023.9998372396014423815743004207",
"-0x3ff.fff55555693e93c7a725540#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Nearest,
"1023.9998372396014423815743004207",
"0x3ff.fff55555693e93c7a725540#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Nearest,
"-1023.9998372396014423815743004207",
"-0x3ff.fff55555693e93c7a725540#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Down,
"1023.9998372396014423815743004207",
"0x3ff.fff55555693e93c7a725540#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Down,
"-1023.9998372396014423815743004207",
"-0x3ff.fff55555693e93c7a725540#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Up,
"1023.9998372396014423815743004215",
"0x3ff.fff55555693e93c7a725544#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Up,
"-1023.9998372396014423815743004215",
"-0x3ff.fff55555693e93c7a725544#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Floor,
"1125899906842623.9999999999999991",
"0x3ffffffffffff.ffffffffffffc#100",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Floor,
"-1125899906842624.0000000000000000",
"-0x4000000000000.0000000000000#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Ceiling,
"1125899906842624.0000000000000000",
"0x4000000000000.0000000000000#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Ceiling,
"-1125899906842623.9999999999999991",
"-0x3ffffffffffff.ffffffffffffc#100",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Nearest,
"1125899906842624.0000000000000000",
"0x4000000000000.0000000000000#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Nearest,
"-1125899906842624.0000000000000000",
"-0x4000000000000.0000000000000#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Down,
"1125899906842623.9999999999999991",
"0x3ffffffffffff.ffffffffffffc#100",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Down,
"-1125899906842623.9999999999999991",
"-0x3ffffffffffff.ffffffffffffc#100",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Up,
"1125899906842624.0000000000000000",
"0x4000000000000.0000000000000#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Up,
"-1125899906842624.0000000000000000",
"-0x4000000000000.0000000000000#100",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Floor,
"1.2664e30",
"0xf.fcE+24#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Floor,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Ceiling,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Ceiling,
"-1.2664e30",
"-0xf.fcE+24#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Nearest,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Nearest,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Down,
"1.2664e30",
"0xf.fcE+24#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Down,
"-1.2664e30",
"-0xf.fcE+24#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Up,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Up,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Floor,
"1267650600228229401496703205375.9999999999999999999999999999998685231824631646990980452391\
193",
"0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Floor,
"-1267650600228229401496703205375.999999999999999999999999999999868523182463164699098045239\
1200",
"-0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555556#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Ceiling,
"1267650600228229401496703205375.9999999999999999999999999999998685231824631646990980452391\
200",
"0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555556#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Ceiling,
"-1267650600228229401496703205375.999999999999999999999999999999868523182463164699098045239\
1193",
"-0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Nearest,
"1267650600228229401496703205375.9999999999999999999999999999998685231824631646990980452391\
193",
"0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Nearest,
"-1267650600228229401496703205375.999999999999999999999999999999868523182463164699098045239\
1193",
"-0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Down,
"1267650600228229401496703205375.9999999999999999999999999999998685231824631646990980452391\
193",
"0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Down,
"-1267650600228229401496703205375.999999999999999999999999999999868523182463164699098045239\
1193",
"-0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555555#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Up,
"1267650600228229401496703205375.9999999999999999999999999999998685231824631646990980452391\
200",
"0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555556#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Up,
"-1267650600228229401496703205375.999999999999999999999999999999868523182463164699098045239\
1200",
"-0xfffffffffffffffffffffffff.fffffffffffffffffffffffffd555555555555555555555556#300",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Floor,
"2.09857871646738769229e323228496",
"0x7.fffffffffffffff8E+268435455#64",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Down,
"2.09857871646738769229e323228496",
"0x7.fffffffffffffff8E+268435455#64",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Up,
"Infinity",
"Infinity",
Greater,
);
test(
"623740651.00",
"0x252d86eb.0#30",
1,
Floor,
"2.7e-270887123",
"0x2.0E-224966886#1",
Less,
);
test(
"623740651.00",
"0x252d86eb.0#30",
1,
Ceiling,
"5.4e-270887123",
"0x4.0E-224966886#1",
Greater,
);
test(
"623740651.00",
"0x252d86eb.0#30",
1,
Nearest,
"2.7e-270887123",
"0x2.0E-224966886#1",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
10,
Down,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
10,
Up,
"Infinity",
"Infinity",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
10,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Floor,
"-Infinity",
"-Infinity",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Ceiling,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Down,
"-2.0965e323228496",
"-0x7.feE+268435455#10",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Up,
"-Infinity",
"-Infinity",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Nearest,
"-Infinity",
"-Infinity",
Less,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Floor,
"1.0483e323228496",
"0x3.ffE+268435455#10",
Less,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Ceiling,
"1.0493e323228496",
"0x4.00E+268435455#10",
Greater,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Down,
"1.0483e323228496",
"0x3.ffE+268435455#10",
Less,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Up,
"1.0493e323228496",
"0x4.00E+268435455#10",
Greater,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Nearest,
"1.0493e323228496",
"0x4.00E+268435455#10",
Greater,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Floor,
"-1.0493e323228496",
"-0x4.00E+268435455#10",
Less,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Ceiling,
"-1.0483e323228496",
"-0x3.ffE+268435455#10",
Greater,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Down,
"-1.0483e323228496",
"-0x3.ffE+268435455#10",
Greater,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Up,
"-1.0493e323228496",
"-0x4.00E+268435455#10",
Less,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Nearest,
"-1.0493e323228496",
"-0x4.00E+268435455#10",
Less,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Floor,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Ceiling,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Down,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Up,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Nearest,
"-0.0",
"-0x0.0",
Greater,
);
test(
"2.4e-30",
"0x3.0E-25#2",
10,
Floor,
"4.2214e29",
"0x5.54E+24#10",
Less,
);
test(
"0.000976562500000000000000",
"0x0.0040000000000000000#64",
10,
Floor,
"1023.0",
"0x3ff.0#10",
Less,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Floor,
"-1024.0",
"-0x400.0#10",
Less,
);
test(
"2.4e-30",
"0x3.0E-25#2",
10,
Ceiling,
"4.2276e29",
"0x5.56E+24#10",
Greater,
);
test(
"0.000976562500000000000000",
"0x0.0040000000000000000#64",
10,
Ceiling,
"1024.0",
"0x400.0#10",
Greater,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Ceiling,
"-1023.0",
"-0x3ff.0#10",
Greater,
);
test(
"2.4e-30",
"0x3.0E-25#2",
10,
Nearest,
"4.2276e29",
"0x5.56E+24#10",
Greater,
);
test(
"0.000976562500000000000000",
"0x0.0040000000000000000#64",
10,
Nearest,
"1024.0",
"0x400.0#10",
Greater,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Nearest,
"-1024.0",
"-0x400.0#10",
Less,
);
}
#[test]
#[should_panic]
fn csch_prec_round_fail() {
Float::ONE.csch_prec_round(0, Nearest);
}
#[test]
#[should_panic]
fn csch_prec_round_exact_fail() {
Float::ONE.csch_prec_round(10, Exact);
}
#[test]
#[should_panic]
fn csch_prec_fail() {
Float::ONE.csch_prec(0);
}
#[test]
#[should_panic]
fn csch_round_fail() {
Float::ONE.csch_round(Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn csch_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {
let (c, o) = x.clone().csch_prec_round(prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.csch_prec_round_ref(prec, rm);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.csch_prec_round_assign(prec, rm);
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_c, rug_o) = rug_csch_prec_round(&rug::Float::exact_from(&x), prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
let (c_neg, o_neg) = (-&x).csch_prec_round(prec, -rm);
assert_eq!(ComparableFloatRef(&c_neg), ComparableFloatRef(&-&c));
assert_eq!(o_neg, o.reverse());
if !x.is_nan() {
assert_eq!(c.is_sign_positive(), x.is_sign_positive());
}
if x.is_normal() {
let r = x.reciprocal_prec_round_ref(prec, rm).0;
if x > 0u32 {
assert!(c <= r);
} else {
assert!(c >= r);
}
}
if c.is_normal() {
assert_eq!(c.get_prec(), Some(prec));
}
if o == Equal {
for rm2 in exhaustive_rounding_modes() {
let (c2, o2) = x.csch_prec_round_ref(prec, rm2);
assert_eq!(ComparableFloat(c2), ComparableFloat(c.clone()));
assert_eq!(o2, Equal);
}
} else {
assert_panic!(x.csch_prec_round_ref(prec, Exact));
}
}
#[test]
fn csch_prec_round_properties() {
float_unsigned_rounding_mode_triple_gen_var_36().test_properties(|(x, prec, rm)| {
csch_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::NAN.csch_prec_round(prec, rm);
assert!(c.is_nan());
assert_eq!(o, Equal);
let (c, o) = Float::INFINITY.csch_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::ZERO));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_INFINITY.csch_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::NEGATIVE_ZERO));
assert_eq!(o, Equal);
let (c, o) = Float::ZERO.csch_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::INFINITY));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_ZERO.csch_prec_round(prec, rm);
assert_eq!(
ComparableFloat(c),
ComparableFloat(Float::NEGATIVE_INFINITY)
);
assert_eq!(o, Equal);
});
}
#[test]
fn csch_round_properties() {
float_rounding_mode_pair_gen_var_47().test_properties(|(x, rm)| {
let (c, o) = x.clone().csch_round(rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.csch_round_ref(rm);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.csch_round_assign(rm);
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (c_alt, o_alt) = x.csch_prec_round_ref(x.significant_bits(), rm);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_c, rug_o) = rug_csch_round(&rug::Float::exact_from(&x), rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
});
}
#[test]
fn csch_prec_properties() {
float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {
let (c, o) = x.clone().csch_prec(prec);
assert!(c.is_valid());
let (c_alt, o_alt) = x.csch_prec_ref(prec);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.csch_prec_assign(prec);
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (c_alt, o_alt) = x.csch_prec_round_ref(prec, Nearest);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (rug_c, rug_o) = rug_csch_prec(&rug::Float::exact_from(&x), prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
});
}
#[test]
fn csch_properties() {
float_gen().test_properties(|x| {
let c = x.clone().csch();
assert!(c.is_valid());
let c_alt = (&x).csch();
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
let mut x_alt = x.clone();
x_alt.csch_assign();
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
let c_alt = x.csch_prec_round_ref(x.significant_bits(), Nearest).0;
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(
ComparableFloatRef(&<Float as From<&rug::Float>>::from(&rug_csch(
&rug::Float::exact_from(&x)
))),
ComparableFloatRef(&c)
);
assert_eq!(ComparableFloatRef(&(-&x).csch()), ComparableFloatRef(&-&c));
if !x.is_nan() {
assert_eq!(c.is_sign_positive(), x.is_sign_positive());
}
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_csch() {
fn test<T: PrimitiveFloat>(x: T, out: T)
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
assert_eq!(NiceFloat(primitive_float_csch(x)), NiceFloat(out));
}
test::<f32>(f32::NAN, f32::NAN);
test::<f32>(f32::INFINITY, 0.0);
test::<f32>(f32::NEGATIVE_INFINITY, -0.0);
test::<f32>(0.0, f32::INFINITY);
test::<f32>(-0.0, f32::NEGATIVE_INFINITY);
test::<f32>(1.0, 0.8509181);
test::<f32>(-1.0, -0.8509181);
test::<f32>(0.5, 1.9190347);
test::<f32>(2.0, 0.27572057);
test::<f32>(10.0, 0.00009079986);
test::<f32>(88.0, 1.2109204e-38);
test::<f32>(89.0, 4.454728e-39);
test::<f32>(95.0, 1.1042e-41);
test::<f32>(100.0, 7.4e-44);
test::<f32>(104.0, 1.0e-45);
test::<f32>(1.0e-20, 1.0e20);
test::<f32>(1.0e-38, 1.0000001e38);
test::<f32>(3.0e-39, 3.3333327e38);
test::<f32>(1.0e-45, f32::INFINITY);
test::<f32>(3.4028235e38, 0.0);
test::<f64>(f64::NAN, f64::NAN);
test::<f64>(f64::INFINITY, 0.0);
test::<f64>(f64::NEGATIVE_INFINITY, -0.0);
test::<f64>(0.0, f64::INFINITY);
test::<f64>(-0.0, f64::NEGATIVE_INFINITY);
test::<f64>(1.0, 0.8509181282393216);
test::<f64>(-1.0, -0.8509181282393216);
test::<f64>(0.5, 1.9190347513349437);
test::<f64>(2.0, 0.2757205647717832);
test::<f64>(10.0, 0.00009079985971212217);
test::<f64>(700.0, 1.971935308751954e-304);
test::<f64>(710.0, 8.95257245135026e-309);
test::<f64>(720.0, 4.06446160484e-313);
test::<f64>(744.0, 1.5e-323);
test::<f64>(745.0, 5.0e-324);
test::<f64>(746.0, 0.0);
test::<f64>(1.0e-200, 1.0e200);
test::<f64>(1.0e-308, 1.0e308);
test::<f64>(5.0e-309, f64::INFINITY);
test::<f64>(5.0e-324, f64::INFINITY);
test::<f64>(1.7976931348623157e308, 0.0);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_csch_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 c = primitive_float_csch(x);
assert_eq!(c.is_nan(), x.is_nan());
if !x.is_nan() {
assert_eq!(c.is_sign_positive(), x.is_sign_positive());
assert_eq!(NiceFloat(primitive_float_csch(-x)), NiceFloat(-c));
}
if x.is_finite() {
let rug_c: T = round_once_to_primitive(|p| {
<Float as From<&rug::Float>>::from(
&rug_csch_prec(&rug::Float::exact_from(&Float::from(x)), p).0,
)
});
assert_eq!(NiceFloat(rug_c), NiceFloat(c));
}
});
}
#[test]
fn primitive_float_csch_properties() {
apply_fn_to_primitive_floats!(primitive_float_csch_properties_helper);
}
#[test]
fn test_csch_rational_prec_round() {
let test = |s, prec, rm, out: &str, out_hex: &str, out_o| {
let x = Rational::from_str(s).unwrap();
let (c, o) = Float::csch_rational_prec_round(x.clone(), prec, rm);
assert!(c.is_valid());
assert_eq!(c.to_string(), out);
assert_eq!(to_hex_string(&c), out_hex);
assert_eq!(o, out_o);
let (c, o) = Float::csch_rational_prec_round_ref(&x, prec, rm);
assert!(c.is_valid());
assert_eq!(c.to_string(), out);
assert_eq!(to_hex_string(&c), out_hex);
assert_eq!(o, out_o);
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_c, rug_o) = rug_csch_rational_prec_round(&x, prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
};
test("0", 1, Down, "Infinity", "Infinity", Equal);
test("0", 10, Down, "Infinity", "Infinity", Equal);
test("0", 1, Up, "Infinity", "Infinity", Equal);
test("0", 10, Up, "Infinity", "Infinity", Equal);
test("0", 1, Floor, "Infinity", "Infinity", Equal);
test("0", 10, Floor, "Infinity", "Infinity", Equal);
test("0", 1, Ceiling, "Infinity", "Infinity", Equal);
test("0", 10, Ceiling, "Infinity", "Infinity", Equal);
test("0", 1, Nearest, "Infinity", "Infinity", Equal);
test("0", 10, Nearest, "Infinity", "Infinity", Equal);
test("0", 1, Exact, "Infinity", "Infinity", Equal);
test("0", 10, Exact, "Infinity", "Infinity", Equal);
test("3/5", 1, Floor, "1.0", "0x1.0#1", Less);
test("3/5", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("3/5", 1, Nearest, "2.0", "0x2.0#1", Greater);
test("3/5", 10, Floor, "1.5703", "0x1.920#10", Less);
test("3/5", 10, Ceiling, "1.5723", "0x1.928#10", Greater);
test("3/5", 10, Nearest, "1.5703", "0x1.920#10", Less);
test(
"3/5",
100,
Floor,
"1.5707129089350753418197932853841",
"0x1.921a3dbf47fb12065464e2540#100",
Less,
);
test(
"3/5",
100,
Ceiling,
"1.5707129089350753418197932853856",
"0x1.921a3dbf47fb12065464e2542#100",
Greater,
);
test(
"3/5",
100,
Nearest,
"1.5707129089350753418197932853856",
"0x1.921a3dbf47fb12065464e2542#100",
Greater,
);
test("-3/5", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-3/5", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-3/5", 1, Nearest, "-2.0", "-0x2.0#1", Less);
test("-3/5", 10, Floor, "-1.5723", "-0x1.928#10", Less);
test("-3/5", 10, Ceiling, "-1.5703", "-0x1.920#10", Greater);
test("-3/5", 10, Nearest, "-1.5703", "-0x1.920#10", Greater);
test(
"-3/5",
100,
Floor,
"-1.5707129089350753418197932853856",
"-0x1.921a3dbf47fb12065464e2542#100",
Less,
);
test(
"-3/5",
100,
Ceiling,
"-1.5707129089350753418197932853841",
"-0x1.921a3dbf47fb12065464e2540#100",
Greater,
);
test(
"-3/5",
100,
Nearest,
"-1.5707129089350753418197932853856",
"-0x1.921a3dbf47fb12065464e2542#100",
Less,
);
test("1/3", 1, Floor, "2.0", "0x2.0#1", Less);
test("1/3", 1, Ceiling, "4.0", "0x4.0#1", Greater);
test("1/3", 1, Nearest, "2.0", "0x2.0#1", Less);
test("1/3", 10, Floor, "2.9414", "0x2.f1#10", Less);
test("1/3", 10, Ceiling, "2.9453", "0x2.f2#10", Greater);
test("1/3", 10, Nearest, "2.9453", "0x2.f2#10", Greater);
test(
"1/3",
100,
Floor,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Less,
);
test(
"1/3",
100,
Ceiling,
"2.9451562666948143476455860034982",
"0x2.f1f5c2d7104d708fac22e7c70#100",
Greater,
);
test(
"1/3",
100,
Nearest,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Less,
);
test("22/7", 1, Floor, "0.062", "0x0.1#1", Less);
test("22/7", 1, Ceiling, "0.12", "0x0.2#1", Greater);
test("22/7", 1, Nearest, "0.062", "0x0.1#1", Less);
test("22/7", 10, Floor, "0.086426", "0x0.1620#10", Less);
test("22/7", 10, Ceiling, "0.086548", "0x0.1628#10", Greater);
test("22/7", 10, Nearest, "0.086426", "0x0.1620#10", Less);
test(
"22/7",
100,
Floor,
"0.086479706518627875891032052705382",
"0x0.162388b743e325b1326cd6dab8#100",
Less,
);
test(
"22/7",
100,
Ceiling,
"0.086479706518627875891032052705481",
"0x0.162388b743e325b1326cd6daba#100",
Greater,
);
test(
"22/7",
100,
Nearest,
"0.086479706518627875891032052705382",
"0x0.162388b743e325b1326cd6dab8#100",
Less,
);
test("100", 1, Floor, "4.5e-44", "0x1.0E-36#1", Less);
test("100", 1, Ceiling, "9.0e-44", "0x2.0E-36#1", Greater);
test("100", 1, Nearest, "9.0e-44", "0x2.0E-36#1", Greater);
test("100", 10, Floor, "7.4356e-44", "0x1.a88E-36#10", Less);
test("100", 10, Ceiling, "7.4444e-44", "0x1.a90E-36#10", Greater);
test("100", 10, Nearest, "7.4444e-44", "0x1.a90E-36#10", Greater);
test(
"100",
100,
Floor,
"7.4401519520416719259193916077216e-44",
"0x1.a8c1f14e2af5caf3dd91375c6E-36#100",
Less,
);
test(
"100",
100,
Ceiling,
"7.4401519520416719259193916077287e-44",
"0x1.a8c1f14e2af5caf3dd91375c8E-36#100",
Greater,
);
test(
"100",
100,
Nearest,
"7.4401519520416719259193916077287e-44",
"0x1.a8c1f14e2af5caf3dd91375c8E-36#100",
Greater,
);
test("-100", 1, Floor, "-9.0e-44", "-0x2.0E-36#1", Less);
test("-100", 1, Ceiling, "-4.5e-44", "-0x1.0E-36#1", Greater);
test("-100", 1, Nearest, "-9.0e-44", "-0x2.0E-36#1", Less);
test("-100", 10, Floor, "-7.4444e-44", "-0x1.a90E-36#10", Less);
test(
"-100",
10,
Ceiling,
"-7.4356e-44",
"-0x1.a88E-36#10",
Greater,
);
test("-100", 10, Nearest, "-7.4444e-44", "-0x1.a90E-36#10", Less);
test(
"-100",
100,
Floor,
"-7.4401519520416719259193916077287e-44",
"-0x1.a8c1f14e2af5caf3dd91375c8E-36#100",
Less,
);
test(
"-100",
100,
Ceiling,
"-7.4401519520416719259193916077216e-44",
"-0x1.a8c1f14e2af5caf3dd91375c6E-36#100",
Greater,
);
test(
"-100",
100,
Nearest,
"-7.4401519520416719259193916077287e-44",
"-0x1.a8c1f14e2af5caf3dd91375c8E-36#100",
Less,
);
test("1/1000", 1, Floor, "5.1e2", "0x2.0E+2#1", Less);
test("1/1000", 1, Ceiling, "1.0e3", "0x4.0E+2#1", Greater);
test("1/1000", 1, Nearest, "1.0e3", "0x4.0E+2#1", Greater);
test("1/1000", 10, Floor, "999.00", "0x3e7.0#10", Less);
test("1/1000", 10, Ceiling, "1000.0", "0x3e8.0#10", Greater);
test("1/1000", 10, Nearest, "1000.0", "0x3e8.0#10", Greater);
test(
"1/1000",
100,
Floor,
"999.99983333335277777572751343712",
"0x3e7.fff513cc336aae69e615430#100",
Less,
);
test(
"1/1000",
100,
Ceiling,
"999.99983333335277777572751343793",
"0x3e7.fff513cc336aae69e615434#100",
Greater,
);
test(
"1/1000",
100,
Nearest,
"999.99983333335277777572751343712",
"0x3e7.fff513cc336aae69e615430#100",
Less,
);
test("-1/1000000", 1, Floor, "-1.0e6", "-0x1.0E+5#1", Less);
test("-1/1000000", 1, Ceiling, "-5.2e5", "-0x8.0E+4#1", Greater);
test("-1/1000000", 1, Nearest, "-1.0e6", "-0x1.0E+5#1", Less);
test("-1/1000000", 10, Floor, "-1.0004e6", "-0xf.44E+4#10", Less);
test(
"-1/1000000",
10,
Ceiling,
"-9.9942e5",
"-0xf.40E+4#10",
Greater,
);
test(
"-1/1000000",
10,
Nearest,
"-1.0004e6",
"-0xf.44E+4#10",
Less,
);
test(
"-1/1000000",
100,
Floor,
"-999999.99999983333333333335277852",
"-0xf423f.fffffd342c0fe1ae19a0#100",
Less,
);
test(
"-1/1000000",
100,
Ceiling,
"-999999.99999983333333333335277769",
"-0xf423f.fffffd342c0fe1ae199f#100",
Greater,
);
test(
"-1/1000000",
100,
Nearest,
"-999999.99999983333333333335277769",
"-0xf423f.fffffd342c0fe1ae199f#100",
Greater,
);
test(
"1/100000000000000000000",
1,
Floor,
"7.4e19",
"0x4.0E+16#1",
Less,
);
test(
"1/100000000000000000000",
1,
Ceiling,
"1.5e20",
"0x8.0E+16#1",
Greater,
);
test(
"1/100000000000000000000",
1,
Nearest,
"7.4e19",
"0x4.0E+16#1",
Less,
);
test(
"1/100000000000000000000",
10,
Floor,
"9.9872e19",
"0x5.6aE+16#10",
Less,
);
test(
"1/100000000000000000000",
10,
Ceiling,
"1.0002e20",
"0x5.6cE+16#10",
Greater,
);
test(
"1/100000000000000000000",
10,
Nearest,
"1.0002e20",
"0x5.6cE+16#10",
Greater,
);
test(
"1/100000000000000000000",
100,
Floor,
"99999999999999999999.999999999884",
"0x56bc75e2d630fffff.ffffffff8#100",
Less,
);
test(
"1/100000000000000000000",
100,
Ceiling,
"100000000000000000000.00000000000",
"0x56bc75e2d63100000.000000000#100",
Greater,
);
test(
"1/100000000000000000000",
100,
Nearest,
"100000000000000000000.00000000000",
"0x56bc75e2d63100000.000000000#100",
Greater,
);
test(
"1488522235/2",
1,
Floor,
"4.8e-323228497",
"0x2.0E-268435456#1",
Less,
);
test(
"1488522235/2",
1,
Ceiling,
"9.5e-323228497",
"0x4.0E-268435456#1",
Greater,
);
test(
"1488522235/2",
1,
Nearest,
"9.5e-323228497",
"0x4.0E-268435456#1",
Greater,
);
test(
"1488522235/2",
10,
Floor,
"7.5014e-323228497",
"0x3.26E-268435456#10",
Less,
);
test(
"1488522235/2",
10,
Ceiling,
"7.5107e-323228497",
"0x3.27E-268435456#10",
Greater,
);
test(
"1488522235/2",
10,
Nearest,
"7.5107e-323228497",
"0x3.27E-268435456#10",
Greater,
);
test(
"1488522235/2",
100,
Floor,
"7.5098673083218467310380527281516e-323228497",
"0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Less,
);
test(
"1488522235/2",
100,
Ceiling,
"7.5098673083218467310380527281592e-323228497",
"0x3.26ea18e02da8f8a2632086efcE-268435456#100",
Greater,
);
test(
"1488522235/2",
100,
Nearest,
"7.5098673083218467310380527281516e-323228497",
"0x3.26ea18e02da8f8a2632086ef8E-268435456#100",
Less,
);
test(
"7442611177/10",
1,
Floor,
"4.8e-323228497",
"0x2.0E-268435456#1",
Less,
);
test(
"7442611177/10",
1,
Ceiling,
"9.5e-323228497",
"0x4.0E-268435456#1",
Greater,
);
test(
"7442611177/10",
1,
Nearest,
"4.8e-323228497",
"0x2.0E-268435456#1",
Less,
);
test(
"7442611177/10",
10,
Floor,
"6.1426e-323228497",
"0x2.94E-268435456#10",
Less,
);
test(
"7442611177/10",
10,
Ceiling,
"6.1519e-323228497",
"0x2.95E-268435456#10",
Greater,
);
test(
"7442611177/10",
10,
Nearest,
"6.1519e-323228497",
"0x2.95E-268435456#10",
Greater,
);
test(
"7442611177/10",
100,
Floor,
"6.1485593168580621515208966267134e-323228497",
"0x2.94a54a8d64062c460adda8654E-268435456#100",
Less,
);
test(
"7442611177/10",
100,
Ceiling,
"6.1485593168580621515208966267209e-323228497",
"0x2.94a54a8d64062c460adda8658E-268435456#100",
Greater,
);
test(
"7442611177/10",
100,
Nearest,
"6.1485593168580621515208966267134e-323228497",
"0x2.94a54a8d64062c460adda8654E-268435456#100",
Less,
);
test(
"-7442611185/10",
1,
Floor,
"-4.8e-323228497",
"-0x2.0E-268435456#1",
Less,
);
test(
"-7442611185/10",
1,
Ceiling,
"-2.4e-323228497",
"-0x1.0E-268435456#1",
Greater,
);
test(
"-7442611185/10",
1,
Nearest,
"-2.4e-323228497",
"-0x1.0E-268435456#1",
Greater,
);
test(
"-7442611185/10",
10,
Floor,
"-2.7641e-323228497",
"-0x1.290E-268435456#10",
Less,
);
test(
"-7442611185/10",
10,
Ceiling,
"-2.7595e-323228497",
"-0x1.288E-268435456#10",
Greater,
);
test(
"-7442611185/10",
10,
Nearest,
"-2.7641e-323228497",
"-0x1.290E-268435456#10",
Less,
);
test(
"-7442611185/10",
100,
Floor,
"-2.7627257886571247097149806988033e-323228497",
"-0x1.28d8e45434c7216121ffbfc58E-268435456#100",
Less,
);
test(
"-7442611185/10",
100,
Ceiling,
"-2.7627257886571247097149806987996e-323228497",
"-0x1.28d8e45434c7216121ffbfc56E-268435456#100",
Greater,
);
test(
"-7442611185/10",
100,
Nearest,
"-2.7627257886571247097149806988033e-323228497",
"-0x1.28d8e45434c7216121ffbfc58E-268435456#100",
Less,
);
test("744261119", 1, Floor, "0.0", "0x0.0", Less);
test(
"744261119",
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test(
"744261119",
1,
Nearest,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test("744261119", 10, Floor, "0.0", "0x0.0", Less);
test(
"744261119",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"744261119",
10,
Nearest,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test("744261119", 100, Floor, "0.0", "0x0.0", Less);
test(
"744261119",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"744261119",
100,
Nearest,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test("7442611196/10", 1, Floor, "0.0", "0x0.0", Less);
test(
"7442611196/10",
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test("7442611196/10", 1, Nearest, "0.0", "0x0.0", Less);
test("7442611196/10", 10, Floor, "0.0", "0x0.0", Less);
test(
"7442611196/10",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test("7442611196/10", 10, Nearest, "0.0", "0x0.0", Less);
test("7442611196/10", 100, Floor, "0.0", "0x0.0", Less);
test(
"7442611196/10",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test("7442611196/10", 100, Nearest, "0.0", "0x0.0", Less);
test("744261120", 1, Floor, "0.0", "0x0.0", Less);
test(
"744261120",
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test("744261120", 1, Nearest, "0.0", "0x0.0", Less);
test("744261120", 10, Floor, "0.0", "0x0.0", Less);
test(
"744261120",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test("744261120", 10, Nearest, "0.0", "0x0.0", Less);
test("744261120", 100, Floor, "0.0", "0x0.0", Less);
test(
"744261120",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test("744261120", 100, Nearest, "0.0", "0x0.0", Less);
test("10000000000", 1, Floor, "0.0", "0x0.0", Less);
test(
"10000000000",
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test("10000000000", 1, Nearest, "0.0", "0x0.0", Less);
test("10000000000", 10, Floor, "0.0", "0x0.0", Less);
test(
"10000000000",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test("10000000000", 10, Nearest, "0.0", "0x0.0", Less);
test("10000000000", 100, Floor, "0.0", "0x0.0", Less);
test(
"10000000000",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test("10000000000", 100, Nearest, "0.0", "0x0.0", Less);
test(
"1/1000",
100,
Down,
"999.99983333335277777572751343712",
"0x3e7.fff513cc336aae69e615430#100",
Less,
);
test("744261119", 100, Down, "0.0", "0x0.0", Less);
test(
"1/1000",
100,
Up,
"999.99983333335277777572751343793",
"0x3e7.fff513cc336aae69e615434#100",
Greater,
);
test(
"744261119",
100,
Up,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test("2/13", 7, Floor, "6.438", "0x6.7#7", Less);
test("2/13", 7, Ceiling, "6.500", "0x6.8#7", Greater);
test("2/13", 7, Nearest, "6.500", "0x6.8#7", Greater);
test(
"1/1267650600228229401496703205376",
10,
Floor,
"1.2664e30",
"0xf.fcE+24#10",
Less,
);
test(
"-1/1267650600228229401496703205376",
10,
Floor,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"1/3802951800684688204490109616129",
10,
Floor,
"3.8030e30",
"0x3.00E+25#10",
Less,
);
test(
"1/1267650600228229401496703205377",
100,
Floor,
"1267650600228229401496703205376.0",
"0x10000000000000000000000000.0#100",
Less,
);
test(
"-1/1267650600228229401496703205377",
100,
Floor,
"-1267650600228229401496703205378.0",
"-0x10000000000000000000000002.0#100",
Less,
);
test("-22/7", 20, Floor, "-0.086479783", "-0x0.16238a#20", Less);
test("-1/1000", 10, Floor, "-1000.0", "-0x3e8.0#10", Less);
test(
"-744261120",
10,
Floor,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"100000000000000000000000000000000000000000000000000",
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"1/1267650600228229401496703205376",
10,
Ceiling,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-1/1267650600228229401496703205376",
10,
Ceiling,
"-1.2664e30",
"-0xf.fcE+24#10",
Greater,
);
test(
"1/3802951800684688204490109616129",
10,
Ceiling,
"3.8079e30",
"0x3.01E+25#10",
Greater,
);
test(
"1/1267650600228229401496703205377",
100,
Ceiling,
"1267650600228229401496703205378.0",
"0x10000000000000000000000002.0#100",
Greater,
);
test(
"-1/1267650600228229401496703205377",
100,
Ceiling,
"-1267650600228229401496703205376.0",
"-0x10000000000000000000000000.0#100",
Greater,
);
test(
"-22/7",
20,
Ceiling,
"-0.086479664",
"-0x0.162388#20",
Greater,
);
test("-1/1000", 10, Ceiling, "-999.00", "-0x3e7.0#10", Greater);
test("-744261120", 10, Ceiling, "-0.0", "-0x0.0", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"1/1267650600228229401496703205376",
10,
Down,
"1.2664e30",
"0xf.fcE+24#10",
Less,
);
test(
"-1/1267650600228229401496703205376",
10,
Down,
"-1.2664e30",
"-0xf.fcE+24#10",
Greater,
);
test(
"1/3802951800684688204490109616129",
10,
Down,
"3.8030e30",
"0x3.00E+25#10",
Less,
);
test(
"1/1267650600228229401496703205377",
100,
Down,
"1267650600228229401496703205376.0",
"0x10000000000000000000000000.0#100",
Less,
);
test(
"-1/1267650600228229401496703205377",
100,
Down,
"-1267650600228229401496703205376.0",
"-0x10000000000000000000000000.0#100",
Greater,
);
test(
"1/3",
100,
Down,
"2.9451562666948143476455860034951",
"0x2.f1f5c2d7104d708fac22e7c6c#100",
Less,
);
test("-22/7", 20, Down, "-0.086479664", "-0x0.162388#20", Greater);
test("1/1000", 10, Down, "999.00", "0x3e7.0#10", Less);
test("-1/1000", 10, Down, "-999.00", "-0x3e7.0#10", Greater);
test("744261120", 10, Down, "0.0", "0x0.0", Less);
test("-744261120", 10, Down, "-0.0", "-0x0.0", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Down,
"0.0",
"0x0.0",
Less,
);
test(
"1/1267650600228229401496703205376",
10,
Up,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-1/1267650600228229401496703205376",
10,
Up,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"1/3802951800684688204490109616129",
10,
Up,
"3.8079e30",
"0x3.01E+25#10",
Greater,
);
test(
"1/1267650600228229401496703205377",
100,
Up,
"1267650600228229401496703205378.0",
"0x10000000000000000000000002.0#100",
Greater,
);
test(
"-1/1267650600228229401496703205377",
100,
Up,
"-1267650600228229401496703205378.0",
"-0x10000000000000000000000002.0#100",
Less,
);
test(
"1/3",
100,
Up,
"2.9451562666948143476455860034982",
"0x2.f1f5c2d7104d708fac22e7c70#100",
Greater,
);
test("-22/7", 20, Up, "-0.086479783", "-0x0.16238a#20", Less);
test("1/1000", 10, Up, "1000.0", "0x3e8.0#10", Greater);
test("-1/1000", 10, Up, "-1000.0", "-0x3e8.0#10", Less);
test(
"744261120",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"-744261120",
10,
Up,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"100000000000000000000000000000000000000000000000000",
10,
Up,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test(
"1/1267650600228229401496703205376",
10,
Nearest,
"1.2677e30",
"0x1.000E+25#10",
Greater,
);
test(
"-1/1267650600228229401496703205376",
10,
Nearest,
"-1.2677e30",
"-0x1.000E+25#10",
Less,
);
test(
"1/3802951800684688204490109616129",
10,
Nearest,
"3.8030e30",
"0x3.00E+25#10",
Less,
);
test(
"1/1267650600228229401496703205377",
100,
Nearest,
"1267650600228229401496703205376.0",
"0x10000000000000000000000000.0#100",
Less,
);
test(
"-1/1267650600228229401496703205377",
100,
Nearest,
"-1267650600228229401496703205376.0",
"-0x10000000000000000000000000.0#100",
Greater,
);
test(
"-22/7",
20,
Nearest,
"-0.086479664",
"-0x0.162388#20",
Greater,
);
test("-1/1000", 10, Nearest, "-1000.0", "-0x3e8.0#10", Less);
test("-744261120", 10, Nearest, "-0.0", "-0x0.0", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test(
"3/257",
40,
Floor,
"85.664721172303",
"0x55.aa2b2ab00#40",
Less,
);
test(
"3/257",
40,
Ceiling,
"85.664721172419",
"0x55.aa2b2ab08#40",
Greater,
);
test(
"3/257",
40,
Nearest,
"85.664721172303",
"0x55.aa2b2ab00#40",
Less,
);
}
#[test]
fn test_csch_rational_extreme() {
let x = Rational::power_of_2(-(1i64 << 30) - 10);
let max = Float::max_finite_value_with_prec(10);
for (rm, out, o_out) in [
(Floor, max.clone(), Less),
(Down, max.clone(), Less),
(Nearest, Float::INFINITY, Greater),
(Ceiling, Float::INFINITY, Greater),
(Up, Float::INFINITY, Greater),
] {
let (c, o) = Float::csch_rational_prec_round_ref(&x, 10, rm);
assert_eq!(ComparableFloatRef(&c), ComparableFloatRef(&out));
assert_eq!(o, o_out);
let (c_neg, o_neg) = Float::csch_rational_prec_round(-&x, 10, -rm);
assert_eq!(ComparableFloat(c_neg), ComparableFloat(-c));
assert_eq!(o_neg, o.reverse());
}
let x = Rational::power_of_2(1i64 << 30);
let (c, o) = Float::csch_rational_prec_round_ref(&x, 10, Nearest);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::ZERO));
assert_eq!(o, Less);
let (c, o) = Float::csch_rational_prec_round(-x, 10, Up);
assert_eq!(
ComparableFloat(c),
ComparableFloat(-Float::min_positive_value_prec(10))
);
assert_eq!(o, Less);
}
#[test]
#[should_panic]
fn csch_rational_prec_fail() {
Float::csch_rational_prec(Rational::ONE, 0);
}
#[test]
#[should_panic]
fn csch_rational_prec_ref_fail() {
Float::csch_rational_prec_ref(&Rational::ONE, 0);
}
#[test]
#[should_panic]
fn csch_rational_prec_round_fail_1() {
Float::csch_rational_prec_round(Rational::ONE, 0, Floor);
}
#[test]
#[should_panic]
fn csch_rational_prec_round_fail_2() {
Float::csch_rational_prec_round(Rational::ONE, 10, Exact);
}
#[test]
#[should_panic]
fn csch_rational_prec_round_ref_fail() {
Float::csch_rational_prec_round_ref(&Rational::ONE, 10, Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn csch_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {
let (c, o) = Float::csch_rational_prec_round(x.clone(), prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = Float::csch_rational_prec_round_ref(&x, prec, rm);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
if x != 0u32 {
assert_eq!(c.is_sign_positive(), x > 0u32);
let (c_neg, o_neg) = Float::csch_rational_prec_round(-&x, prec, -rm);
assert_eq!(ComparableFloatRef(&c_neg), ComparableFloatRef(&-&c));
assert_eq!(o_neg, o.reverse());
}
if let Ok(rrm) = rug_round_try_from_rounding_mode(rm) {
let (rug_c, rug_o) = rug_csch_rational_prec_round(&x, prec, rrm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
if c.is_normal() {
assert_eq!(c.get_prec(), Some(prec));
}
if o == Equal {
for rm in exhaustive_rounding_modes() {
let (s, oo) = Float::csch_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&s), ComparableFloatRef(&c));
assert_eq!(oo, Equal);
}
} else {
assert_panic!(Float::csch_rational_prec_round_ref(&x, prec, Exact));
}
}
#[test]
fn csch_rational_prec_round_properties() {
rational_unsigned_rounding_mode_triple_gen_var_10().test_properties(|(x, prec, rm)| {
csch_rational_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::csch_rational_prec_round(Rational::ZERO, prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::INFINITY));
assert_eq!(o, Equal);
});
}
#[allow(clippy::needless_pass_by_value)]
fn csch_rational_prec_properties_helper(x: Rational, prec: u64) {
let (c, o) = Float::csch_rational_prec(x.clone(), prec);
assert!(c.is_valid());
let (c_alt, o_alt) = Float::csch_rational_prec_ref(&x, prec);
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (c_alt, o_alt) = Float::csch_rational_prec_round_ref(&x, prec, Nearest);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (rug_c, rug_o) = rug_csch_rational_prec(&x, prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
if x != 0u32
&& let Ok(f) = Float::try_from(&x)
{
let (c_alt, o_alt) = f.csch_prec(prec);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
}
}
#[test]
fn csch_rational_prec_properties() {
rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {
csch_rational_prec_properties_helper(x, prec);
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_csch_rational() {
fn test<T: PrimitiveFloat>(s: &str, out: T)
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
let x = Rational::from_str(s).unwrap();
assert_eq!(
NiceFloat(primitive_float_csch_rational::<T>(&x)),
NiceFloat(out)
);
}
test::<f32>("0", f32::INFINITY);
test::<f32>("1", 0.8509181);
test::<f32>("-1", -0.8509181);
test::<f32>("1/3", 2.9451563);
test::<f32>("22/7", 0.08647971);
test::<f32>("95", 1.1042e-41);
test::<f32>("100", 7.4e-44);
test::<f32>("104", 1.0e-45);
test::<f32>("710", 0.0);
test::<f32>("720", 0.0);
test::<f32>("-745", -0.0);
test::<f32>("7451/10", 0.0);
test::<f32>("746", 0.0);
test::<f32>("10000", 0.0);
test::<f32>("1/100000000000000000000", 1.0e20);
test::<f32>("1/10000000000000000000000000000000000000000", f32::INFINITY);
test::<f32>(
"-1/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000",
f32::NEGATIVE_INFINITY,
);
test::<f64>("0", f64::INFINITY);
test::<f64>("1", 0.8509181282393216);
test::<f64>("-1", -0.8509181282393216);
test::<f64>("1/3", 2.9451562666948146);
test::<f64>("22/7", 0.08647970651862788);
test::<f64>("95", 1.1042164554057065e-41);
test::<f64>("100", 7.440151952041672e-44);
test::<f64>("104", 1.3627113643090597e-45);
test::<f64>("710", 8.95257245135026e-309);
test::<f64>("720", 4.06446160484e-313);
test::<f64>("-745", -5.0e-324);
test::<f64>("7451/10", 5.0e-324);
test::<f64>("746", 0.0);
test::<f64>("10000", 0.0);
test::<f64>("1/100000000000000000000", 1.0e20);
test::<f64>("1/10000000000000000000000000000000000000000", 1.0e40);
test::<f64>(
"-1/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000",
f64::NEGATIVE_INFINITY,
);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_csch_rational_properties_helper<T: PrimitiveFloat>()
where
Float: From<T> + PartialOrd<T>,
Rational: ExactFrom<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
rational_gen().test_properties(|x| {
let c = primitive_float_csch_rational::<T>(&x);
assert!(!c.is_nan());
if x != 0u32 {
assert_eq!(c.is_sign_positive(), x > 0u32);
assert_eq!(
NiceFloat(primitive_float_csch_rational::<T>(&-&x)),
NiceFloat(-c)
);
}
let spare = if x == 0u32 {
64
} else {
64 + (x.floor_log_base_2_abs().unsigned_abs() << 1)
};
let rug_c = rug_csch_rational_prec(&x, T::MANTISSA_WIDTH + spare).0;
let rug_c: T = T::rounding_from(&<Float as From<&rug::Float>>::from(&rug_c), Nearest).0;
assert_eq!(NiceFloat(rug_c), NiceFloat(c));
});
primitive_float_gen::<T>().test_properties(|x| {
if x.is_finite() && x != T::ZERO {
assert_eq!(
NiceFloat(primitive_float_csch_rational::<T>(&Rational::exact_from(x))),
NiceFloat(primitive_float_csch(x))
);
}
});
}
#[test]
fn primitive_float_csch_rational_properties() {
apply_fn_to_primitive_floats!(primitive_float_csch_rational_properties_helper);
}