use core::cmp::Ordering::{self, *};
use malachite_base::num::arithmetic::traits::{Coth, CothAssign, 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::coth::{
primitive_float_coth, primitive_float_coth_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::coth::{
rug_coth, rug_coth_prec, rug_coth_prec_round, rug_coth_rational_prec,
rug_coth_rational_prec_round, rug_coth_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_coth_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().coth_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.coth_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.coth_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_coth_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, "1.0", "0x1.0#1", Equal);
test(
"-Infinity",
"-Infinity",
1,
Nearest,
"-1.0",
"-0x1.0#1",
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, "1.0", "0x1.0#1", Less);
test("1.0", "0x1.0#1", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("1.0", "0x1.0#1", 1, Nearest, "1.0", "0x1.0#1", Less);
test("1.0", "0x1.0#1", 10, Floor, "1.3125", "0x1.500#10", Less);
test(
"1.0",
"0x1.0#1",
10,
Ceiling,
"1.3145",
"0x1.508#10",
Greater,
);
test("1.0", "0x1.0#1", 10, Nearest, "1.3125", "0x1.500#10", Less);
test(
"1.0",
"0x1.0#1",
100,
Floor,
"1.3130352854993313036361612469298",
"0x1.50231499b6b1d49f813a188f8#100",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Ceiling,
"1.3130352854993313036361612469313",
"0x1.50231499b6b1d49f813a188fa#100",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Nearest,
"1.3130352854993313036361612469313",
"0x1.50231499b6b1d49f813a188fa#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Floor,
"-1.3145",
"-0x1.508#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
10,
Ceiling,
"-1.3125",
"-0x1.500#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Nearest,
"-1.3125",
"-0x1.500#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Down,
"-1.3125",
"-0x1.500#10",
Greater,
);
test("-1.0", "-0x1.0#1", 10, Up, "-1.3145", "-0x1.508#10", Less);
test(
"-1.0",
"-0x1.0#1",
100,
Floor,
"-1.3130352854993313036361612469313",
"-0x1.50231499b6b1d49f813a188fa#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Ceiling,
"-1.3130352854993313036361612469298",
"-0x1.50231499b6b1d49f813a188f8#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Nearest,
"-1.3130352854993313036361612469313",
"-0x1.50231499b6b1d49f813a188fa#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Down,
"-1.3130352854993313036361612469298",
"-0x1.50231499b6b1d49f813a188f8#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Up,
"-1.3130352854993313036361612469313",
"-0x1.50231499b6b1d49f813a188fa#100",
Less,
);
test("0.50", "0x0.8#1", 10, Floor, "2.1602", "0x2.29#10", Less);
test(
"0.50",
"0x0.8#1",
10,
Ceiling,
"2.1641",
"0x2.2a#10",
Greater,
);
test(
"0.50",
"0x0.8#1",
10,
Nearest,
"2.1641",
"0x2.2a#10",
Greater,
);
test("0.50", "0x0.8#1", 10, Down, "2.1602", "0x2.29#10", Less);
test("0.50", "0x0.8#1", 10, Up, "2.1641", "0x2.2a#10", Greater);
test(
"0.50",
"0x0.8#1",
100,
Floor,
"2.1639534137386528487700040102170",
"0x2.29f8d9d61337dbaab838a8ad8#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Ceiling,
"2.1639534137386528487700040102201",
"0x2.29f8d9d61337dbaab838a8adc#100",
Greater,
);
test(
"0.50",
"0x0.8#1",
100,
Nearest,
"2.1639534137386528487700040102170",
"0x2.29f8d9d61337dbaab838a8ad8#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Down,
"2.1639534137386528487700040102170",
"0x2.29f8d9d61337dbaab838a8ad8#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Up,
"2.1639534137386528487700040102201",
"0x2.29f8d9d61337dbaab838a8adc#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Floor,
"3.1094",
"0x3.1c#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Ceiling,
"3.1133",
"0x3.1d#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Nearest,
"3.1094",
"0x3.1c#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Down,
"3.1094",
"0x3.1c#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Up,
"3.1133",
"0x3.1d#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Floor,
"3.1102966796194437013783752314146",
"0x3.1c3c6737d2a99a2538dde3dbc#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Ceiling,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Nearest,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Down,
"3.1102966796194437013783752314146",
"0x3.1c3c6737d2a99a2538dde3dbc#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Up,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test("2.0", "0x2.0#2", 10, Floor, "1.0371", "0x1.098#10", Less);
test(
"2.0",
"0x2.0#2",
10,
Ceiling,
"1.0391",
"0x1.0a0#10",
Greater,
);
test("2.0", "0x2.0#2", 10, Nearest, "1.0371", "0x1.098#10", Less);
test("2.0", "0x2.0#2", 10, Down, "1.0371", "0x1.098#10", Less);
test("2.0", "0x2.0#2", 10, Up, "1.0391", "0x1.0a0#10", Greater);
test(
"2.0",
"0x2.0#2",
100,
Floor,
"1.0373147207275480958778097647664",
"0x1.098d75212f273ba5d96804eca#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Ceiling,
"1.0373147207275480958778097647680",
"0x1.098d75212f273ba5d96804ecc#100",
Greater,
);
test(
"2.0",
"0x2.0#2",
100,
Nearest,
"1.0373147207275480958778097647680",
"0x1.098d75212f273ba5d96804ecc#100",
Greater,
);
test(
"2.0",
"0x2.0#2",
100,
Down,
"1.0373147207275480958778097647664",
"0x1.098d75212f273ba5d96804eca#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Up,
"1.0373147207275480958778097647680",
"0x1.098d75212f273ba5d96804ecc#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-10.0",
"-0xa.0#4",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test("-10.0", "-0xa.0#4", 10, Up, "-1.0020", "-0x1.008#10", Less);
test(
"-10.0",
"-0xa.0#4",
100,
Floor,
"-1.0000000041223072533738241840291",
"-0x1.00000011b48656902ef938492#100",
Less,
);
test(
"-10.0",
"-0xa.0#4",
100,
Ceiling,
"-1.0000000041223072533738241840275",
"-0x1.00000011b48656902ef938490#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Nearest,
"-1.0000000041223072533738241840275",
"-0x1.00000011b48656902ef938490#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Down,
"-1.0000000041223072533738241840275",
"-0x1.00000011b48656902ef938490#100",
Greater,
);
test(
"-10.0",
"-0xa.0#4",
100,
Up,
"-1.0000000041223072533738241840291",
"-0x1.00000011b48656902ef938492#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Floor,
"1.0020",
"0x1.008#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Ceiling,
"1.0039",
"0x1.010#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Nearest,
"1.0039",
"0x1.010#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Down,
"1.0020",
"0x1.008#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Up,
"1.0039",
"0x1.010#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Floor,
"1.0037418731973212882011765623462",
"0x1.00f53a37021e3cccc69b27e42#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Ceiling,
"1.0037418731973212882011765623478",
"0x1.00f53a37021e3cccc69b27e44#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Nearest,
"1.0037418731973212882011765623462",
"0x1.00f53a37021e3cccc69b27e42#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Down,
"1.0037418731973212882011765623462",
"0x1.00f53a37021e3cccc69b27e42#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Up,
"1.0037418731973212882011765623478",
"0x1.00f53a37021e3cccc69b27e44#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"5.4e8",
"0x2.0E+7#1",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Up,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Down,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Up,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261118.50",
"0x2c5c85fe.8#31",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.00000",
"0x2c5c85ff.000#40",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.29980",
"0x2c5c85ff.4cc#40",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
10,
Up,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Down,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-744261119.59961",
"-0x2c5c85ff.998#40",
100,
Up,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119.90039",
"0x2c5c85ff.e68#40",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261120.00",
"0x2c5c8600.0#30",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Floor,
"1024.0",
"0x400.0#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Floor,
"-1026.0",
"-0x402.0#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Ceiling,
"1026.0",
"0x402.0#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Ceiling,
"-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,
Nearest,
"-1024.0",
"-0x400.0#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Down,
"1024.0",
"0x400.0#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Down,
"-1024.0",
"-0x400.0#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Up,
"1026.0",
"0x402.0#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Up,
"-1026.0",
"-0x402.0#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Floor,
"1024.0003255208126372779993985406",
"0x400.001555553e93e96140be7f0#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Floor,
"-1024.0003255208126372779993985422",
"-0x400.001555553e93e96140be7f8#100",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Ceiling,
"1024.0003255208126372779993985422",
"0x400.001555553e93e96140be7f8#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Ceiling,
"-1024.0003255208126372779993985406",
"-0x400.001555553e93e96140be7f0#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Nearest,
"1024.0003255208126372779993985406",
"0x400.001555553e93e96140be7f0#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Nearest,
"-1024.0003255208126372779993985406",
"-0x400.001555553e93e96140be7f0#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Down,
"1024.0003255208126372779993985406",
"0x400.001555553e93e96140be7f0#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Down,
"-1024.0003255208126372779993985406",
"-0x400.001555553e93e96140be7f0#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Up,
"1024.0003255208126372779993985422",
"0x400.001555553e93e96140be7f8#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Up,
"-1024.0003255208126372779993985422",
"-0x400.001555553e93e96140be7f8#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,
Floor,
"-1125899906842624.0000000000000018",
"-0x4000000000000.0000000000008#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Ceiling,
"1125899906842624.0000000000000018",
"0x4000000000000.0000000000008#100",
Greater,
);
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,
Nearest,
"1125899906842624.0000000000000000",
"0x4000000000000.0000000000000#100",
Less,
);
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,
Down,
"1125899906842624.0000000000000000",
"0x4000000000000.0000000000000#100",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Down,
"-1125899906842624.0000000000000000",
"-0x4000000000000.0000000000000#100",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Up,
"1125899906842624.0000000000000018",
"0x4000000000000.0000000000008#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Up,
"-1125899906842624.0000000000000018",
"-0x4000000000000.0000000000008#100",
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,
Floor,
"-1.2701e30",
"-0x1.008E+25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Ceiling,
"1.2701e30",
"0x1.008E+25#10",
Greater,
);
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,
Nearest,
"1.2677e30",
"0x1.000E+25#10",
Less,
);
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,
Down,
"1.2677e30",
"0x1.000E+25#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Down,
"-1.2677e30",
"-0x1.000E+25#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Up,
"1.2701e30",
"0x1.008E+25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Up,
"-1.2701e30",
"-0x1.008E+25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Floor,
"1267650600228229401496703205376.0000000000000000000000000000002629536350736706018039095217\
601",
"0x10000000000000000000000000.00000000000000000000000005555555555555555555555554#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Floor,
"-1267650600228229401496703205376.000000000000000000000000000000262953635073670601803909521\
7613",
"-0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Ceiling,
"1267650600228229401496703205376.0000000000000000000000000000002629536350736706018039095217\
613",
"0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Ceiling,
"-1267650600228229401496703205376.000000000000000000000000000000262953635073670601803909521\
7601",
"-0x10000000000000000000000000.00000000000000000000000005555555555555555555555554#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Nearest,
"1267650600228229401496703205376.0000000000000000000000000000002629536350736706018039095217\
613",
"0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Nearest,
"-1267650600228229401496703205376.000000000000000000000000000000262953635073670601803909521\
7613",
"-0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Down,
"1267650600228229401496703205376.0000000000000000000000000000002629536350736706018039095217\
601",
"0x10000000000000000000000000.00000000000000000000000005555555555555555555555554#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Down,
"-1267650600228229401496703205376.000000000000000000000000000000262953635073670601803909521\
7601",
"-0x10000000000000000000000000.00000000000000000000000005555555555555555555555554#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Up,
"1267650600228229401496703205376.0000000000000000000000000000002629536350736706018039095217\
613",
"0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Up,
"-1267650600228229401496703205376.000000000000000000000000000000262953635073670601803909521\
7613",
"-0x10000000000000000000000000.00000000000000000000000005555555555555555555555556#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,
"1.0",
"0x1.0#1",
Less,
);
test(
"623740651.00",
"0x252d86eb.0#30",
1,
Ceiling,
"2.0",
"0x2.0#1",
Greater,
);
test(
"623740651.00",
"0x252d86eb.0#30",
1,
Nearest,
"1.0",
"0x1.0#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.0493e323228496",
"0x4.00E+268435455#10",
Less,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Ceiling,
"1.0513e323228496",
"0x4.02E+268435455#10",
Greater,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Down,
"1.0493e323228496",
"0x4.00E+268435455#10",
Less,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Up,
"1.0513e323228496",
"0x4.02E+268435455#10",
Greater,
);
test(
"9.5e-323228497",
"0x4.0E-268435456#1",
10,
Nearest,
"1.0493e323228496",
"0x4.00E+268435455#10",
Less,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Floor,
"-1.0513e323228496",
"-0x4.02E+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.0493e323228496",
"-0x4.00E+268435455#10",
Greater,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Up,
"-1.0513e323228496",
"-0x4.02E+268435455#10",
Less,
);
test(
"-9.5e-323228497",
"-0x4.0E-268435456#1",
10,
Nearest,
"-1.0493e323228496",
"-0x4.00E+268435455#10",
Greater,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Up,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-744261120.00",
"-0x2c5c8600.0#32",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
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,
"1024.0",
"0x400.0#10",
Less,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Floor,
"-1026.0",
"-0x402.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,
"1026.0",
"0x402.0#10",
Greater,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Ceiling,
"-1024.0",
"-0x400.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",
Less,
);
test(
"-0.000976562500000000000000",
"-0x0.0040000000000000000#64",
10,
Nearest,
"-1024.0",
"-0x400.0#10",
Greater,
);
test("20.0", "0x14.0#5", 1, Floor, "1.0", "0x1.0#1", Less);
test("20.0", "0x14.0#5", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("20.0", "0x14.0#5", 1, Down, "1.0", "0x1.0#1", Less);
test("20.0", "0x14.0#5", 1, Up, "2.0", "0x2.0#1", Greater);
test("20.0", "0x14.0#5", 1, Nearest, "1.0", "0x1.0#1", Less);
test("20.0", "0x14.0#5", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"20.0",
"0x14.0#5",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("20.0", "0x14.0#5", 10, Down, "1.0000", "0x1.000#10", Less);
test("20.0", "0x14.0#5", 10, Up, "1.0020", "0x1.008#10", Greater);
test(
"20.0",
"0x14.0#5",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"20.0",
"0x14.0#5",
64,
Floor,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20.0",
"0x14.0#5",
64,
Ceiling,
"1.00000000000000000857",
"0x1.000000000000009e#64",
Greater,
);
test(
"20.0",
"0x14.0#5",
64,
Down,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20.0",
"0x14.0#5",
64,
Up,
"1.00000000000000000857",
"0x1.000000000000009e#64",
Greater,
);
test(
"20.0",
"0x14.0#5",
64,
Nearest,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20.0",
"0x14.0#5",
100,
Floor,
"1.0000000000000000084967085105823",
"0x1.000000000000009cbc924cd8c#100",
Less,
);
test(
"20.0",
"0x14.0#5",
100,
Ceiling,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test(
"20.0",
"0x14.0#5",
100,
Down,
"1.0000000000000000084967085105823",
"0x1.000000000000009cbc924cd8c#100",
Less,
);
test(
"20.0",
"0x14.0#5",
100,
Up,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test(
"20.0",
"0x14.0#5",
100,
Nearest,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test("-20.0", "-0x14.0#5", 1, Floor, "-2.0", "-0x2.0#1", Less);
test(
"-20.0",
"-0x14.0#5",
1,
Ceiling,
"-1.0",
"-0x1.0#1",
Greater,
);
test("-20.0", "-0x14.0#5", 1, Down, "-1.0", "-0x1.0#1", Greater);
test("-20.0", "-0x14.0#5", 1, Up, "-2.0", "-0x2.0#1", Less);
test(
"-20.0",
"-0x14.0#5",
1,
Nearest,
"-1.0",
"-0x1.0#1",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-20.0",
"-0x14.0#5",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test("-20.0", "-0x14.0#5", 10, Up, "-1.0020", "-0x1.008#10", Less);
test(
"-20.0",
"-0x14.0#5",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
64,
Floor,
"-1.00000000000000000857",
"-0x1.000000000000009e#64",
Less,
);
test(
"-20.0",
"-0x14.0#5",
64,
Ceiling,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
64,
Down,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
64,
Up,
"-1.00000000000000000857",
"-0x1.000000000000009e#64",
Less,
);
test(
"-20.0",
"-0x14.0#5",
64,
Nearest,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
100,
Floor,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test(
"-20.0",
"-0x14.0#5",
100,
Ceiling,
"-1.0000000000000000084967085105823",
"-0x1.000000000000009cbc924cd8c#100",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
100,
Down,
"-1.0000000000000000084967085105823",
"-0x1.000000000000009cbc924cd8c#100",
Greater,
);
test(
"-20.0",
"-0x14.0#5",
100,
Up,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test(
"-20.0",
"-0x14.0#5",
100,
Nearest,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test("256.0", "0x100.0#9", 1, Floor, "1.0", "0x1.0#1", Less);
test("256.0", "0x100.0#9", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("256.0", "0x100.0#9", 1, Down, "1.0", "0x1.0#1", Less);
test("256.0", "0x100.0#9", 1, Up, "2.0", "0x2.0#1", Greater);
test("256.0", "0x100.0#9", 1, Nearest, "1.0", "0x1.0#1", Less);
test(
"256.0",
"0x100.0#9",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"256.0",
"0x100.0#9",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("256.0", "0x100.0#9", 10, Down, "1.0000", "0x1.000#10", Less);
test(
"256.0",
"0x100.0#9",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"256.0",
"0x100.0#9",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"256.0",
"0x100.0#9",
64,
Floor,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"256.0",
"0x100.0#9",
64,
Ceiling,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"256.0",
"0x100.0#9",
64,
Down,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"256.0",
"0x100.0#9",
64,
Up,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"256.0",
"0x100.0#9",
64,
Nearest,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"256.0",
"0x100.0#9",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"256.0",
"0x100.0#9",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"256.0",
"0x100.0#9",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"256.0",
"0x100.0#9",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"256.0",
"0x100.0#9",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("-256.0", "-0x100.0#9", 1, Floor, "-2.0", "-0x2.0#1", Less);
test(
"-256.0",
"-0x100.0#9",
1,
Ceiling,
"-1.0",
"-0x1.0#1",
Greater,
);
test("-256.0", "-0x100.0#9", 1, Down, "-1.0", "-0x1.0#1", Greater);
test("-256.0", "-0x100.0#9", 1, Up, "-2.0", "-0x2.0#1", Less);
test(
"-256.0",
"-0x100.0#9",
1,
Nearest,
"-1.0",
"-0x1.0#1",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
10,
Floor,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-256.0",
"-0x100.0#9",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
10,
Down,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
10,
Up,
"-1.0020",
"-0x1.008#10",
Less,
);
test(
"-256.0",
"-0x100.0#9",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
64,
Floor,
"-1.00000000000000000011",
"-0x1.0000000000000002#64",
Less,
);
test(
"-256.0",
"-0x100.0#9",
64,
Ceiling,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
64,
Down,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
64,
Up,
"-1.00000000000000000011",
"-0x1.0000000000000002#64",
Less,
);
test(
"-256.0",
"-0x100.0#9",
64,
Nearest,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-256.0",
"-0x100.0#9",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
100,
Down,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-256.0",
"-0x100.0#9",
100,
Up,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-256.0",
"-0x100.0#9",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test("12.0", "0xc.0#4", 1, Floor, "1.0", "0x1.0#1", Less);
test("12.0", "0xc.0#4", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("12.0", "0xc.0#4", 1, Down, "1.0", "0x1.0#1", Less);
test("12.0", "0xc.0#4", 1, Up, "2.0", "0x2.0#1", Greater);
test("12.0", "0xc.0#4", 1, Nearest, "1.0", "0x1.0#1", Less);
test("12.0", "0xc.0#4", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"12.0",
"0xc.0#4",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("12.0", "0xc.0#4", 10, Down, "1.0000", "0x1.000#10", Less);
test("12.0", "0xc.0#4", 10, Up, "1.0020", "0x1.008#10", Greater);
test("12.0", "0xc.0#4", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"12.0",
"0xc.0#4",
64,
Floor,
"1.00000000007550269080",
"0x1.0000000053041e3e#64",
Less,
);
test(
"12.0",
"0xc.0#4",
64,
Ceiling,
"1.00000000007550269090",
"0x1.0000000053041e40#64",
Greater,
);
test(
"12.0",
"0xc.0#4",
64,
Down,
"1.00000000007550269080",
"0x1.0000000053041e3e#64",
Less,
);
test(
"12.0",
"0xc.0#4",
64,
Up,
"1.00000000007550269090",
"0x1.0000000053041e40#64",
Greater,
);
test(
"12.0",
"0xc.0#4",
64,
Nearest,
"1.00000000007550269090",
"0x1.0000000053041e40#64",
Greater,
);
test(
"12.0",
"0xc.0#4",
100,
Floor,
"1.0000000000755026908884322831979",
"0x1.0000000053041e3fb1fffdff8#100",
Less,
);
test(
"12.0",
"0xc.0#4",
100,
Ceiling,
"1.0000000000755026908884322831994",
"0x1.0000000053041e3fb1fffdffa#100",
Greater,
);
test(
"12.0",
"0xc.0#4",
100,
Down,
"1.0000000000755026908884322831979",
"0x1.0000000053041e3fb1fffdff8#100",
Less,
);
test(
"12.0",
"0xc.0#4",
100,
Up,
"1.0000000000755026908884322831994",
"0x1.0000000053041e3fb1fffdffa#100",
Greater,
);
test(
"12.0",
"0xc.0#4",
100,
Nearest,
"1.0000000000755026908884322831979",
"0x1.0000000053041e3fb1fffdff8#100",
Less,
);
test("1.0", "0x1.0#1", 1, Down, "1.0", "0x1.0#1", Less);
test("1.0", "0x1.0#1", 1, Up, "2.0", "0x2.0#1", Greater);
test("1.0", "0x1.0#1", 10, Down, "1.3125", "0x1.500#10", Less);
test("1.0", "0x1.0#1", 10, Up, "1.3145", "0x1.508#10", Greater);
test(
"1.0",
"0x1.0#1",
64,
Floor,
"1.31303528549933130355",
"0x1.50231499b6b1d49e#64",
Less,
);
test(
"1.0",
"0x1.0#1",
64,
Ceiling,
"1.31303528549933130366",
"0x1.50231499b6b1d4a0#64",
Greater,
);
test(
"1.0",
"0x1.0#1",
64,
Down,
"1.31303528549933130355",
"0x1.50231499b6b1d49e#64",
Less,
);
test(
"1.0",
"0x1.0#1",
64,
Up,
"1.31303528549933130366",
"0x1.50231499b6b1d4a0#64",
Greater,
);
test(
"1.0",
"0x1.0#1",
64,
Nearest,
"1.31303528549933130366",
"0x1.50231499b6b1d4a0#64",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Down,
"1.3130352854993313036361612469298",
"0x1.50231499b6b1d49f813a188f8#100",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Up,
"1.3130352854993313036361612469313",
"0x1.50231499b6b1d49f813a188fa#100",
Greater,
);
test("8.00", "0x8.0#4", 1, Floor, "1.0", "0x1.0#1", Less);
test("8.00", "0x8.0#4", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("8.00", "0x8.0#4", 1, Down, "1.0", "0x1.0#1", Less);
test("8.00", "0x8.0#4", 1, Up, "2.0", "0x2.0#1", Greater);
test("8.00", "0x8.0#4", 1, Nearest, "1.0", "0x1.0#1", Less);
test("8.00", "0x8.0#4", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"8.00",
"0x8.0#4",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("8.00", "0x8.0#4", 10, Down, "1.0000", "0x1.000#10", Less);
test("8.00", "0x8.0#4", 10, Up, "1.0020", "0x1.008#10", Greater);
test("8.00", "0x8.0#4", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"8.00",
"0x8.0#4",
64,
Floor,
"1.00000022507037476685",
"0x1.000003c6ab7e7eea#64",
Less,
);
test(
"8.00",
"0x8.0#4",
64,
Ceiling,
"1.00000022507037476696",
"0x1.000003c6ab7e7eec#64",
Greater,
);
test(
"8.00",
"0x8.0#4",
64,
Down,
"1.00000022507037476685",
"0x1.000003c6ab7e7eea#64",
Less,
);
test(
"8.00",
"0x8.0#4",
64,
Up,
"1.00000022507037476696",
"0x1.000003c6ab7e7eec#64",
Greater,
);
test(
"8.00",
"0x8.0#4",
64,
Nearest,
"1.00000022507037476685",
"0x1.000003c6ab7e7eea#64",
Less,
);
test(
"8.00",
"0x8.0#4",
100,
Floor,
"1.0000002250703747668521775443869",
"0x1.000003c6ab7e7eea04a97bc96#100",
Less,
);
test(
"8.00",
"0x8.0#4",
100,
Ceiling,
"1.0000002250703747668521775443885",
"0x1.000003c6ab7e7eea04a97bc98#100",
Greater,
);
test(
"8.00",
"0x8.0#4",
100,
Down,
"1.0000002250703747668521775443869",
"0x1.000003c6ab7e7eea04a97bc96#100",
Less,
);
test(
"8.00",
"0x8.0#4",
100,
Up,
"1.0000002250703747668521775443885",
"0x1.000003c6ab7e7eea04a97bc98#100",
Greater,
);
test(
"8.00",
"0x8.0#4",
100,
Nearest,
"1.0000002250703747668521775443885",
"0x1.000003c6ab7e7eea04a97bc98#100",
Greater,
);
test("64.00", "0x40.0#7", 1, Floor, "1.0", "0x1.0#1", Less);
test("64.00", "0x40.0#7", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("64.00", "0x40.0#7", 1, Down, "1.0", "0x1.0#1", Less);
test("64.00", "0x40.0#7", 1, Up, "2.0", "0x2.0#1", Greater);
test("64.00", "0x40.0#7", 1, Nearest, "1.0", "0x1.0#1", Less);
test("64.00", "0x40.0#7", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"64.00",
"0x40.0#7",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("64.00", "0x40.0#7", 10, Down, "1.0000", "0x1.000#10", Less);
test("64.00", "0x40.0#7", 10, Up, "1.0020", "0x1.008#10", Greater);
test(
"64.00",
"0x40.0#7",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"64.00",
"0x40.0#7",
64,
Floor,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"64.00",
"0x40.0#7",
64,
Ceiling,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"64.00",
"0x40.0#7",
64,
Down,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"64.00",
"0x40.0#7",
64,
Up,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"64.00",
"0x40.0#7",
64,
Nearest,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"64.00",
"0x40.0#7",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"64.00",
"0x40.0#7",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"64.00",
"0x40.0#7",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"64.00",
"0x40.0#7",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"64.00",
"0x40.0#7",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
}
#[test]
#[should_panic]
fn coth_prec_round_fail() {
Float::ONE.coth_prec_round(0, Nearest);
}
#[test]
#[should_panic]
fn coth_prec_round_exact_fail() {
Float::ONE.coth_prec_round(10, Exact);
}
#[test]
#[should_panic]
fn coth_prec_fail() {
Float::ONE.coth_prec(0);
}
#[test]
#[should_panic]
fn coth_round_fail() {
Float::ONE.coth_round(Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn coth_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {
let (c, o) = x.clone().coth_prec_round(prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.coth_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.coth_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_coth_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).coth_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);
assert!(c >= 1u32);
} else {
assert!(c <= r);
assert!(c <= -1i32);
}
}
if c.is_normal() {
assert_eq!(c.get_prec(), Some(prec));
}
if o == Equal {
for rm2 in exhaustive_rounding_modes() {
let (c2, o2) = x.coth_prec_round_ref(prec, rm2);
assert_eq!(ComparableFloat(c2), ComparableFloat(c.clone()));
assert_eq!(o2, Equal);
}
} else {
assert_panic!(x.coth_prec_round_ref(prec, Exact));
}
}
#[test]
fn coth_prec_round_properties() {
float_unsigned_rounding_mode_triple_gen_var_36().test_properties(|(x, prec, rm)| {
coth_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::NAN.coth_prec_round(prec, rm);
assert!(c.is_nan());
assert_eq!(o, Equal);
let (c, o) = Float::INFINITY.coth_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::one_prec(prec)));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_INFINITY.coth_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(-Float::one_prec(prec)));
assert_eq!(o, Equal);
let (c, o) = Float::ZERO.coth_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::INFINITY));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_ZERO.coth_prec_round(prec, rm);
assert_eq!(
ComparableFloat(c),
ComparableFloat(Float::NEGATIVE_INFINITY)
);
assert_eq!(o, Equal);
});
}
#[test]
fn coth_round_properties() {
float_rounding_mode_pair_gen_var_47().test_properties(|(x, rm)| {
let (c, o) = x.clone().coth_round(rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.coth_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.coth_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.coth_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_coth_round(&rug::Float::exact_from(&x), rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
});
}
#[test]
fn coth_prec_properties() {
float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {
let (c, o) = x.clone().coth_prec(prec);
assert!(c.is_valid());
let (c_alt, o_alt) = x.coth_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.coth_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.coth_prec_round_ref(prec, Nearest);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (rug_c, rug_o) = rug_coth_prec(&rug::Float::exact_from(&x), prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
});
}
#[test]
fn coth_properties() {
float_gen().test_properties(|x| {
let c = x.clone().coth();
assert!(c.is_valid());
let c_alt = (&x).coth();
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
let mut x_alt = x.clone();
x_alt.coth_assign();
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
let c_alt = x.coth_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_coth(
&rug::Float::exact_from(&x)
))),
ComparableFloatRef(&c)
);
assert_eq!(ComparableFloatRef(&(-&x).coth()), 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_coth() {
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_coth(x)), NiceFloat(out));
}
test::<f32>(f32::NAN, f32::NAN);
test::<f32>(f32::INFINITY, 1.0);
test::<f32>(f32::NEGATIVE_INFINITY, -1.0);
test::<f32>(0.0, f32::INFINITY);
test::<f32>(-0.0, f32::NEGATIVE_INFINITY);
test::<f32>(1.0, 1.3130352);
test::<f32>(-1.0, -1.3130352);
test::<f32>(0.5, 2.1639533);
test::<f32>(2.0, 1.0373148);
test::<f32>(10.0, 1.0);
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, 1.0);
test::<f64>(f64::NAN, f64::NAN);
test::<f64>(f64::INFINITY, 1.0);
test::<f64>(f64::NEGATIVE_INFINITY, -1.0);
test::<f64>(0.0, f64::INFINITY);
test::<f64>(-0.0, f64::NEGATIVE_INFINITY);
test::<f64>(1.0, 1.3130352854993312);
test::<f64>(-1.0, -1.3130352854993312);
test::<f64>(0.5, 2.163953413738653);
test::<f64>(2.0, 1.0373147207275482);
test::<f64>(10.0, 1.0000000041223072);
test::<f64>(20.0, 1.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, 1.0);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_coth_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_coth(x);
assert_eq!(c.is_nan(), x.is_nan());
if !x.is_nan() {
assert_eq!(c.is_sign_positive(), x.is_sign_positive());
assert!(c >= T::ONE || c <= T::NEGATIVE_ONE);
assert_eq!(NiceFloat(primitive_float_coth(-x)), NiceFloat(-c));
}
if x.is_finite() {
let rug_c: T = round_once_to_primitive(|p| {
<Float as From<&rug::Float>>::from(
&rug_coth_prec(&rug::Float::exact_from(&Float::from(x)), p).0,
)
});
assert_eq!(NiceFloat(rug_c), NiceFloat(c));
}
});
}
#[test]
fn primitive_float_coth_properties() {
apply_fn_to_primitive_floats!(primitive_float_coth_properties_helper);
}
#[test]
fn test_coth_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::coth_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::coth_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_coth_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.8613", "0x1.dc8#10", Less);
test("3/5", 10, Ceiling, "1.8633", "0x1.dd0#10", Greater);
test("3/5", 10, Nearest, "1.8613", "0x1.dc8#10", Less);
test(
"3/5",
100,
Floor,
"1.8620255213866662476380145582087",
"0x1.dcadb45eac4efa4a942f4f704#100",
Less,
);
test(
"3/5",
100,
Ceiling,
"1.8620255213866662476380145582103",
"0x1.dcadb45eac4efa4a942f4f706#100",
Greater,
);
test(
"3/5",
100,
Nearest,
"1.8620255213866662476380145582087",
"0x1.dcadb45eac4efa4a942f4f704#100",
Less,
);
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.8633", "-0x1.dd0#10", Less);
test("-3/5", 10, Ceiling, "-1.8613", "-0x1.dc8#10", Greater);
test("-3/5", 10, Nearest, "-1.8613", "-0x1.dc8#10", Greater);
test(
"-3/5",
100,
Floor,
"-1.8620255213866662476380145582103",
"-0x1.dcadb45eac4efa4a942f4f706#100",
Less,
);
test(
"-3/5",
100,
Ceiling,
"-1.8620255213866662476380145582087",
"-0x1.dcadb45eac4efa4a942f4f704#100",
Greater,
);
test(
"-3/5",
100,
Nearest,
"-1.8620255213866662476380145582087",
"-0x1.dcadb45eac4efa4a942f4f704#100",
Greater,
);
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, "4.0", "0x4.0#1", Greater);
test("1/3", 10, Floor, "3.1094", "0x3.1c#10", Less);
test("1/3", 10, Ceiling, "3.1133", "0x3.1d#10", Greater);
test("1/3", 10, Nearest, "3.1094", "0x3.1c#10", Less);
test(
"1/3",
100,
Floor,
"3.1102966796194437013783752314146",
"0x3.1c3c6737d2a99a2538dde3dbc#100",
Less,
);
test(
"1/3",
100,
Ceiling,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test(
"1/3",
100,
Nearest,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test("22/7", 1, Floor, "1.0", "0x1.0#1", Less);
test("22/7", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("22/7", 1, Nearest, "1.0", "0x1.0#1", Less);
test("22/7", 10, Floor, "1.0020", "0x1.008#10", Less);
test("22/7", 10, Ceiling, "1.0039", "0x1.010#10", Greater);
test("22/7", 10, Nearest, "1.0039", "0x1.010#10", Greater);
test(
"22/7",
100,
Floor,
"1.0037324043984771186938350250943",
"0x1.00f49b5ad3b018d5106a69232#100",
Less,
);
test(
"22/7",
100,
Ceiling,
"1.0037324043984771186938350250959",
"0x1.00f49b5ad3b018d5106a69234#100",
Greater,
);
test(
"22/7",
100,
Nearest,
"1.0037324043984771186938350250959",
"0x1.00f49b5ad3b018d5106a69234#100",
Greater,
);
test("100", 1, Floor, "1.0", "0x1.0#1", Less);
test("100", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("100", 1, Nearest, "1.0", "0x1.0#1", Less);
test("100", 10, Floor, "1.0000", "0x1.000#10", Less);
test("100", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("100", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"100",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"100",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"100",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("-100", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-100", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-100", 1, Nearest, "-1.0", "-0x1.0#1", Greater);
test("-100", 10, Floor, "-1.0020", "-0x1.008#10", Less);
test("-100", 10, Ceiling, "-1.0000", "-0x1.000#10", Greater);
test("-100", 10, Nearest, "-1.0000", "-0x1.000#10", Greater);
test(
"-100",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-100",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-100",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
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, "1000.0", "0x3e8.0#10", Less);
test("1/1000", 10, Ceiling, "1001.0", "0x3e9.0#10", Greater);
test("1/1000", 10, Nearest, "1000.0", "0x3e8.0#10", Less);
test(
"1/1000",
100,
Floor,
"1000.0003333333111111132275130154",
"0x3e8.0015d867ab7de2ee29e334c#100",
Less,
);
test(
"1/1000",
100,
Ceiling,
"1000.0003333333111111132275130162",
"0x3e8.0015d867ab7de2ee29e3350#100",
Greater,
);
test(
"1/1000",
100,
Nearest,
"1000.0003333333111111132275130162",
"0x3e8.0015d867ab7de2ee29e3350#100",
Greater,
);
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,
"-1000000.0000003333333333333111115",
"-0xf4240.00000597a7e03ca41b77#100",
Less,
);
test(
"-1/1000000",
100,
Ceiling,
"-1000000.0000003333333333333111107",
"-0xf4240.00000597a7e03ca41b76#100",
Greater,
);
test(
"-1/1000000",
100,
Nearest,
"-1000000.0000003333333333333111115",
"-0xf4240.00000597a7e03ca41b77#100",
Less,
);
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,
"100000000000000000000.00000000000",
"0x56bc75e2d63100000.000000000#100",
Less,
);
test(
"1/100000000000000000000",
100,
Ceiling,
"100000000000000000000.00000000012",
"0x56bc75e2d63100000.000000008#100",
Greater,
);
test(
"1/100000000000000000000",
100,
Nearest,
"100000000000000000000.00000000000",
"0x56bc75e2d63100000.000000000#100",
Less,
);
test("1488522235/2", 1, Floor, "1.0", "0x1.0#1", Less);
test("1488522235/2", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("1488522235/2", 1, Nearest, "1.0", "0x1.0#1", Less);
test("1488522235/2", 10, Floor, "1.0000", "0x1.000#10", Less);
test("1488522235/2", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("1488522235/2", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"1488522235/2",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1488522235/2",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"1488522235/2",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("7442611177/10", 1, Floor, "1.0", "0x1.0#1", Less);
test("7442611177/10", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("7442611177/10", 1, Nearest, "1.0", "0x1.0#1", Less);
test("7442611177/10", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"7442611177/10",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("7442611177/10", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"7442611177/10",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"7442611177/10",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"7442611177/10",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("-7442611185/10", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-7442611185/10", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-7442611185/10", 1, Nearest, "-1.0", "-0x1.0#1", Greater);
test("-7442611185/10", 10, Floor, "-1.0020", "-0x1.008#10", Less);
test(
"-7442611185/10",
10,
Ceiling,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-7442611185/10",
10,
Nearest,
"-1.0000",
"-0x1.000#10",
Greater,
);
test(
"-7442611185/10",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-7442611185/10",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-7442611185/10",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test("744261119", 1, Floor, "1.0", "0x1.0#1", Less);
test("744261119", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("744261119", 1, Nearest, "1.0", "0x1.0#1", Less);
test("744261119", 10, Floor, "1.0000", "0x1.000#10", Less);
test("744261119", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("744261119", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"744261119",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261119",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261119",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("7442611196/10", 1, Floor, "1.0", "0x1.0#1", Less);
test("7442611196/10", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("7442611196/10", 1, Nearest, "1.0", "0x1.0#1", Less);
test("7442611196/10", 10, Floor, "1.0000", "0x1.000#10", Less);
test(
"7442611196/10",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test("7442611196/10", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"7442611196/10",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"7442611196/10",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"7442611196/10",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("744261120", 1, Floor, "1.0", "0x1.0#1", Less);
test("744261120", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("744261120", 1, Nearest, "1.0", "0x1.0#1", Less);
test("744261120", 10, Floor, "1.0000", "0x1.000#10", Less);
test("744261120", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("744261120", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"744261120",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"744261120",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"744261120",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("10000000000", 1, Floor, "1.0", "0x1.0#1", Less);
test("10000000000", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("10000000000", 1, Nearest, "1.0", "0x1.0#1", Less);
test("10000000000", 10, Floor, "1.0000", "0x1.000#10", Less);
test("10000000000", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("10000000000", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"10000000000",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"10000000000",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"10000000000",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1/1000",
100,
Down,
"1000.0003333333111111132275130154",
"0x3e8.0015d867ab7de2ee29e334c#100",
Less,
);
test(
"744261119",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"1/1000",
100,
Up,
"1000.0003333333111111132275130162",
"0x3e8.0015d867ab7de2ee29e3350#100",
Greater,
);
test(
"744261119",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test("2/13", 7, Floor, "6.500", "0x6.8#7", Less);
test("2/13", 7, Ceiling, "6.562", "0x6.9#7", Greater);
test("2/13", 7, Nearest, "6.562", "0x6.9#7", Greater);
test(
"1/1267650600228229401496703205376",
10,
Floor,
"1.2677e30",
"0x1.000E+25#10",
Less,
);
test(
"-1/1267650600228229401496703205376",
10,
Floor,
"-1.2701e30",
"-0x1.008E+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, "-1.0037327", "-0x1.00f4a#20", Less);
test("-1/1000", 10, Floor, "-1001.0", "-0x3e9.0#10", Less);
test("-744261120", 10, Floor, "-1.0020", "-0x1.008#10", Less);
test(
"100000000000000000000000000000000000000000000000000",
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/1267650600228229401496703205376",
10,
Ceiling,
"1.2701e30",
"0x1.008E+25#10",
Greater,
);
test(
"-1/1267650600228229401496703205376",
10,
Ceiling,
"-1.2677e30",
"-0x1.000E+25#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, "-1.0037308", "-0x1.00f48#20", Greater);
test("-1/1000", 10, Ceiling, "-1000.0", "-0x3e8.0#10", Greater);
test("-744261120", 10, Ceiling, "-1.0000", "-0x1.000#10", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1/1267650600228229401496703205376",
10,
Down,
"1.2677e30",
"0x1.000E+25#10",
Less,
);
test(
"-1/1267650600228229401496703205376",
10,
Down,
"-1.2677e30",
"-0x1.000E+25#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,
"3.1102966796194437013783752314146",
"0x3.1c3c6737d2a99a2538dde3dbc#100",
Less,
);
test("-22/7", 20, Down, "-1.0037308", "-0x1.00f48#20", Greater);
test("1/1000", 10, Down, "1000.0", "0x3e8.0#10", Less);
test("-1/1000", 10, Down, "-1000.0", "-0x3e8.0#10", Greater);
test("744261120", 10, Down, "1.0000", "0x1.000#10", Less);
test("-744261120", 10, Down, "-1.0000", "-0x1.000#10", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Down,
"1.0000",
"0x1.000#10",
Less,
);
test(
"1/1267650600228229401496703205376",
10,
Up,
"1.2701e30",
"0x1.008E+25#10",
Greater,
);
test(
"-1/1267650600228229401496703205376",
10,
Up,
"-1.2701e30",
"-0x1.008E+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,
"3.1102966796194437013783752314178",
"0x3.1c3c6737d2a99a2538dde3dc0#100",
Greater,
);
test("-22/7", 20, Up, "-1.0037327", "-0x1.00f4a#20", Less);
test("1/1000", 10, Up, "1001.0", "0x3e9.0#10", Greater);
test("-1/1000", 10, Up, "-1001.0", "-0x3e9.0#10", Less);
test("744261120", 10, Up, "1.0020", "0x1.008#10", Greater);
test("-744261120", 10, Up, "-1.0020", "-0x1.008#10", Less);
test(
"100000000000000000000000000000000000000000000000000",
10,
Up,
"1.0020",
"0x1.008#10",
Greater,
);
test(
"1/1267650600228229401496703205376",
10,
Nearest,
"1.2677e30",
"0x1.000E+25#10",
Less,
);
test(
"-1/1267650600228229401496703205376",
10,
Nearest,
"-1.2677e30",
"-0x1.000E+25#10",
Greater,
);
test(
"1/3802951800684688204490109616129",
10,
Nearest,
"3.8030e30",
"0x3.00E+25#10",
Less,
);
test(
"1/1267650600228229401496703205377",
100,
Nearest,
"1267650600228229401496703205378.0",
"0x10000000000000000000000002.0#100",
Greater,
);
test(
"-1/1267650600228229401496703205377",
100,
Nearest,
"-1267650600228229401496703205378.0",
"-0x10000000000000000000000002.0#100",
Less,
);
test("-22/7", 20, Nearest, "-1.0037327", "-0x1.00f4a#20", Less);
test("-1/1000", 10, Nearest, "-1000.0", "-0x3e8.0#10", Greater);
test("-744261120", 10, Nearest, "-1.0000", "-0x1.000#10", Greater);
test(
"100000000000000000000000000000000000000000000000000",
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test(
"3/257",
40,
Floor,
"85.670557681820",
"0x55.aba9ab118#40",
Less,
);
test(
"3/257",
40,
Ceiling,
"85.670557681937",
"0x55.aba9ab120#40",
Greater,
);
test(
"3/257",
40,
Nearest,
"85.670557681937",
"0x55.aba9ab120#40",
Greater,
);
test("20", 1, Floor, "1.0", "0x1.0#1", Less);
test("20", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("20", 1, Down, "1.0", "0x1.0#1", Less);
test("20", 1, Up, "2.0", "0x2.0#1", Greater);
test("20", 1, Nearest, "1.0", "0x1.0#1", Less);
test("20", 10, Floor, "1.0000", "0x1.000#10", Less);
test("20", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("20", 10, Down, "1.0000", "0x1.000#10", Less);
test("20", 10, Up, "1.0020", "0x1.008#10", Greater);
test("20", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"20",
64,
Floor,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20",
64,
Ceiling,
"1.00000000000000000857",
"0x1.000000000000009e#64",
Greater,
);
test(
"20",
64,
Down,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20",
64,
Up,
"1.00000000000000000857",
"0x1.000000000000009e#64",
Greater,
);
test(
"20",
64,
Nearest,
"1.00000000000000000846",
"0x1.000000000000009c#64",
Less,
);
test(
"20",
100,
Floor,
"1.0000000000000000084967085105823",
"0x1.000000000000009cbc924cd8c#100",
Less,
);
test(
"20",
100,
Ceiling,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test(
"20",
100,
Down,
"1.0000000000000000084967085105823",
"0x1.000000000000009cbc924cd8c#100",
Less,
);
test(
"20",
100,
Up,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test(
"20",
100,
Nearest,
"1.0000000000000000084967085105839",
"0x1.000000000000009cbc924cd8e#100",
Greater,
);
test("-20", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-20", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-20", 1, Down, "-1.0", "-0x1.0#1", Greater);
test("-20", 1, Up, "-2.0", "-0x2.0#1", Less);
test("-20", 1, Nearest, "-1.0", "-0x1.0#1", Greater);
test("-20", 10, Floor, "-1.0020", "-0x1.008#10", Less);
test("-20", 10, Ceiling, "-1.0000", "-0x1.000#10", Greater);
test("-20", 10, Down, "-1.0000", "-0x1.000#10", Greater);
test("-20", 10, Up, "-1.0020", "-0x1.008#10", Less);
test("-20", 10, Nearest, "-1.0000", "-0x1.000#10", Greater);
test(
"-20",
64,
Floor,
"-1.00000000000000000857",
"-0x1.000000000000009e#64",
Less,
);
test(
"-20",
64,
Ceiling,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20",
64,
Down,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20",
64,
Up,
"-1.00000000000000000857",
"-0x1.000000000000009e#64",
Less,
);
test(
"-20",
64,
Nearest,
"-1.00000000000000000846",
"-0x1.000000000000009c#64",
Greater,
);
test(
"-20",
100,
Floor,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test(
"-20",
100,
Ceiling,
"-1.0000000000000000084967085105823",
"-0x1.000000000000009cbc924cd8c#100",
Greater,
);
test(
"-20",
100,
Down,
"-1.0000000000000000084967085105823",
"-0x1.000000000000009cbc924cd8c#100",
Greater,
);
test(
"-20",
100,
Up,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test(
"-20",
100,
Nearest,
"-1.0000000000000000084967085105839",
"-0x1.000000000000009cbc924cd8e#100",
Less,
);
test("41/2", 1, Floor, "1.0", "0x1.0#1", Less);
test("41/2", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("41/2", 1, Down, "1.0", "0x1.0#1", Less);
test("41/2", 1, Up, "2.0", "0x2.0#1", Greater);
test("41/2", 1, Nearest, "1.0", "0x1.0#1", Less);
test("41/2", 10, Floor, "1.0000", "0x1.000#10", Less);
test("41/2", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("41/2", 10, Down, "1.0000", "0x1.000#10", Less);
test("41/2", 10, Up, "1.0020", "0x1.008#10", Greater);
test("41/2", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"41/2",
64,
Floor,
"1.00000000000000000304",
"0x1.0000000000000038#64",
Less,
);
test(
"41/2",
64,
Ceiling,
"1.00000000000000000314",
"0x1.000000000000003a#64",
Greater,
);
test(
"41/2",
64,
Down,
"1.00000000000000000304",
"0x1.0000000000000038#64",
Less,
);
test(
"41/2",
64,
Up,
"1.00000000000000000314",
"0x1.000000000000003a#64",
Greater,
);
test(
"41/2",
64,
Nearest,
"1.00000000000000000314",
"0x1.000000000000003a#64",
Greater,
);
test(
"41/2",
100,
Floor,
"1.0000000000000000031257643786692",
"0x1.0000000000000039a901436e8#100",
Less,
);
test(
"41/2",
100,
Ceiling,
"1.0000000000000000031257643786708",
"0x1.0000000000000039a901436ea#100",
Greater,
);
test(
"41/2",
100,
Down,
"1.0000000000000000031257643786692",
"0x1.0000000000000039a901436e8#100",
Less,
);
test(
"41/2",
100,
Up,
"1.0000000000000000031257643786708",
"0x1.0000000000000039a901436ea#100",
Greater,
);
test(
"41/2",
100,
Nearest,
"1.0000000000000000031257643786708",
"0x1.0000000000000039a901436ea#100",
Greater,
);
test("100000", 1, Floor, "1.0", "0x1.0#1", Less);
test("100000", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("100000", 1, Down, "1.0", "0x1.0#1", Less);
test("100000", 1, Up, "2.0", "0x2.0#1", Greater);
test("100000", 1, Nearest, "1.0", "0x1.0#1", Less);
test("100000", 10, Floor, "1.0000", "0x1.000#10", Less);
test("100000", 10, Ceiling, "1.0020", "0x1.008#10", Greater);
test("100000", 10, Down, "1.0000", "0x1.000#10", Less);
test("100000", 10, Up, "1.0020", "0x1.008#10", Greater);
test("100000", 10, Nearest, "1.0000", "0x1.000#10", Less);
test(
"100000",
64,
Floor,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"100000",
64,
Ceiling,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"100000",
64,
Down,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"100000",
64,
Up,
"1.00000000000000000011",
"0x1.0000000000000002#64",
Greater,
);
test(
"100000",
64,
Nearest,
"1.00000000000000000000",
"0x1.0000000000000000#64",
Less,
);
test(
"100000",
100,
Floor,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"100000",
100,
Ceiling,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"100000",
100,
Down,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test(
"100000",
100,
Up,
"1.0000000000000000000000000000016",
"0x1.0000000000000000000000002#100",
Greater,
);
test(
"100000",
100,
Nearest,
"1.0000000000000000000000000000000",
"0x1.0000000000000000000000000#100",
Less,
);
test("-100000", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-100000", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-100000", 1, Down, "-1.0", "-0x1.0#1", Greater);
test("-100000", 1, Up, "-2.0", "-0x2.0#1", Less);
test("-100000", 1, Nearest, "-1.0", "-0x1.0#1", Greater);
test("-100000", 10, Floor, "-1.0020", "-0x1.008#10", Less);
test("-100000", 10, Ceiling, "-1.0000", "-0x1.000#10", Greater);
test("-100000", 10, Down, "-1.0000", "-0x1.000#10", Greater);
test("-100000", 10, Up, "-1.0020", "-0x1.008#10", Less);
test("-100000", 10, Nearest, "-1.0000", "-0x1.000#10", Greater);
test(
"-100000",
64,
Floor,
"-1.00000000000000000011",
"-0x1.0000000000000002#64",
Less,
);
test(
"-100000",
64,
Ceiling,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-100000",
64,
Down,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-100000",
64,
Up,
"-1.00000000000000000011",
"-0x1.0000000000000002#64",
Less,
);
test(
"-100000",
64,
Nearest,
"-1.00000000000000000000",
"-0x1.0000000000000000#64",
Greater,
);
test(
"-100000",
100,
Floor,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-100000",
100,
Ceiling,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-100000",
100,
Down,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test(
"-100000",
100,
Up,
"-1.0000000000000000000000000000016",
"-0x1.0000000000000000000000002#100",
Less,
);
test(
"-100000",
100,
Nearest,
"-1.0000000000000000000000000000000",
"-0x1.0000000000000000000000000#100",
Greater,
);
test("1/1705", 30, Floor, "1705.0001945", "0x6a9.000cc#30", Less);
test(
"1/1705",
30,
Ceiling,
"1705.0001965",
"0x6a9.000ce#30",
Greater,
);
test(
"1/1705",
30,
Nearest,
"1705.0001965",
"0x6a9.000ce#30",
Greater,
);
test("50267/100003", 20, Floor, "2.1542320", "0x2.277bc#20", Less);
test(
"50267/100003",
20,
Ceiling,
"2.1542358",
"0x2.277c0#20",
Greater,
);
test(
"50267/100003",
20,
Nearest,
"2.1542320",
"0x2.277bc#20",
Less,
);
}
#[test]
fn test_coth_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::coth_rational_prec_round_ref(&x, 10, rm);
assert_eq!(ComparableFloatRef(&c), ComparableFloatRef(&out));
assert_eq!(o, o_out);
let (c_neg, o_neg) = Float::coth_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::coth_rational_prec_round_ref(&x, 10, Nearest);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::one_prec(10)));
assert_eq!(o, Less);
let (c, o) = Float::coth_rational_prec_round(-x, 10, Up);
assert_eq!(c.to_string(), "-1.0020");
assert_eq!(c.get_prec(), Some(10));
assert_eq!(o, Less);
}
#[test]
#[should_panic]
fn coth_rational_prec_fail() {
Float::coth_rational_prec(Rational::ONE, 0);
}
#[test]
#[should_panic]
fn coth_rational_prec_ref_fail() {
Float::coth_rational_prec_ref(&Rational::ONE, 0);
}
#[test]
#[should_panic]
fn coth_rational_prec_round_fail_1() {
Float::coth_rational_prec_round(Rational::ONE, 0, Floor);
}
#[test]
#[should_panic]
fn coth_rational_prec_round_fail_2() {
Float::coth_rational_prec_round(Rational::ONE, 10, Exact);
}
#[test]
#[should_panic]
fn coth_rational_prec_round_ref_fail() {
Float::coth_rational_prec_round_ref(&Rational::ONE, 10, Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn coth_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {
let (c, o) = Float::coth_rational_prec_round(x.clone(), prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = Float::coth_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);
assert!(c >= 1u32 || c <= -1i32);
let (c_neg, o_neg) = Float::coth_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_coth_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::coth_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&s), ComparableFloatRef(&c));
assert_eq!(oo, Equal);
}
} else {
assert_panic!(Float::coth_rational_prec_round_ref(&x, prec, Exact));
}
}
#[test]
fn coth_rational_prec_round_properties() {
rational_unsigned_rounding_mode_triple_gen_var_10().test_properties(|(x, prec, rm)| {
coth_rational_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::coth_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 coth_rational_prec_properties_helper(x: Rational, prec: u64) {
let (c, o) = Float::coth_rational_prec(x.clone(), prec);
assert!(c.is_valid());
let (c_alt, o_alt) = Float::coth_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::coth_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_coth_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.coth_prec(prec);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
}
}
#[test]
fn coth_rational_prec_properties() {
rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {
coth_rational_prec_properties_helper(x, prec);
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_coth_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_coth_rational::<T>(&x)),
NiceFloat(out)
);
}
test::<f32>("0", f32::INFINITY);
test::<f32>("1", 1.3130352);
test::<f32>("-1", -1.3130352);
test::<f32>("1/3", 3.1102967);
test::<f32>("22/7", 1.0037324);
test::<f32>("20", 1.0);
test::<f32>("-20", -1.0);
test::<f32>("100", 1.0);
test::<f32>("10000", 1.0);
test::<f32>("1/100000000000000000000", 1.0e20);
test::<f32>("1/10000000000000000000000000000000000000000", f32::INFINITY);
test::<f64>("0", f64::INFINITY);
test::<f64>("1", 1.3130352854993312);
test::<f64>("-1", -1.3130352854993312);
test::<f64>("1/3", 3.110296679619444);
test::<f64>("22/7", 1.0037324043984772);
test::<f64>("20", 1.0);
test::<f64>("-20", -1.0);
test::<f64>("100", 1.0);
test::<f64>("10000", 1.0);
test::<f64>("1/100000000000000000000", 1.0e20);
test::<f64>("1/10000000000000000000000000000000000000000", 1.0e40);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_coth_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_coth_rational::<T>(&x);
assert!(!c.is_nan());
if x != 0u32 {
assert_eq!(c.is_sign_positive(), x > 0u32);
assert!(c >= T::ONE || c <= T::NEGATIVE_ONE);
assert_eq!(
NiceFloat(primitive_float_coth_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_coth_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_coth_rational::<T>(&Rational::exact_from(x))),
NiceFloat(primitive_float_coth(x))
);
}
});
}
#[test]
fn primitive_float_coth_rational_properties() {
apply_fn_to_primitive_floats!(primitive_float_coth_rational_properties_helper);
}