use core::cmp::Ordering::{self, *};
use malachite_base::num::arithmetic::traits::{Asinh, AsinhAssign, PowerOf2};
use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::basic::traits::{
Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,
};
use malachite_base::num::comparison::traits::PartialOrdAbs;
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::asinh::{
primitive_float_asinh, primitive_float_asinh_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::asinh::{
rug_asinh, rug_asinh_prec, rug_asinh_prec_round, rug_asinh_rational_prec,
rug_asinh_rational_prec_round, rug_asinh_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_asinh_prec_round() {
let test = |s: &str,
s_hex: &str,
prec: u64,
rm: RoundingMode,
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().asinh_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.asinh_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.asinh_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_asinh_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, "Infinity", "Infinity", Equal,
);
test(
"-Infinity",
"-Infinity",
1,
Nearest,
"-Infinity",
"-Infinity",
Equal,
);
test("0.0", "0x0.0", 1, Nearest, "0.0", "0x0.0", Equal);
test("-0.0", "-0x0.0", 1, Nearest, "-0.0", "-0x0.0", Equal);
test("0.0", "0x0.0", 10, Nearest, "0.0", "0x0.0", 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.88086", "0x0.e18#10", Less);
test(
"1.0",
"0x1.0#1",
10,
Ceiling,
"0.88184",
"0x0.e1c#10",
Greater,
);
test(
"1.0",
"0x1.0#1",
10,
Nearest,
"0.88184",
"0x0.e1c#10",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Floor,
"0.88137358701954302523260932497968",
"0x0.e1a1b30bcea13660d8f99e8dd#100",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Ceiling,
"0.88137358701954302523260932498047",
"0x0.e1a1b30bcea13660d8f99e8de#100",
Greater,
);
test(
"1.0",
"0x1.0#1",
100,
Nearest,
"0.88137358701954302523260932497968",
"0x0.e1a1b30bcea13660d8f99e8dd#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
10,
Floor,
"-0.88184",
"-0x0.e1c#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
10,
Ceiling,
"-0.88086",
"-0x0.e18#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
10,
Nearest,
"-0.88184",
"-0x0.e1c#10",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Floor,
"-0.88137358701954302523260932498047",
"-0x0.e1a1b30bcea13660d8f99e8de#100",
Less,
);
test(
"-1.0",
"-0x1.0#1",
100,
Ceiling,
"-0.88137358701954302523260932497968",
"-0x0.e1a1b30bcea13660d8f99e8dd#100",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
100,
Nearest,
"-0.88137358701954302523260932497968",
"-0x0.e1a1b30bcea13660d8f99e8dd#100",
Greater,
);
test("0.50", "0x0.8#1", 10, Floor, "0.48096", "0x0.7b2#10", Less);
test(
"0.50",
"0x0.8#1",
10,
Ceiling,
"0.48145",
"0x0.7b4#10",
Greater,
);
test(
"0.50",
"0x0.8#1",
10,
Nearest,
"0.48145",
"0x0.7b4#10",
Greater,
);
test(
"0.50",
"0x0.8#1",
100,
Floor,
"0.48121182505960344749775891342426",
"0x0.7b30b2bb14582652f810812a58#100",
Less,
);
test(
"0.50",
"0x0.8#1",
100,
Ceiling,
"0.48121182505960344749775891342465",
"0x0.7b30b2bb14582652f810812a60#100",
Greater,
);
test(
"0.50",
"0x0.8#1",
100,
Nearest,
"0.48121182505960344749775891342426",
"0x0.7b30b2bb14582652f810812a58#100",
Less,
);
test(
"-0.50",
"-0x0.8#1",
10,
Floor,
"-0.48145",
"-0x0.7b4#10",
Less,
);
test(
"-0.50",
"-0x0.8#1",
10,
Ceiling,
"-0.48096",
"-0x0.7b2#10",
Greater,
);
test(
"-0.50",
"-0x0.8#1",
10,
Nearest,
"-0.48145",
"-0x0.7b4#10",
Less,
);
test(
"-0.50",
"-0x0.8#1",
100,
Floor,
"-0.48121182505960344749775891342465",
"-0x0.7b30b2bb14582652f810812a60#100",
Less,
);
test(
"-0.50",
"-0x0.8#1",
100,
Ceiling,
"-0.48121182505960344749775891342426",
"-0x0.7b30b2bb14582652f810812a58#100",
Greater,
);
test(
"-0.50",
"-0x0.8#1",
100,
Nearest,
"-0.48121182505960344749775891342426",
"-0x0.7b30b2bb14582652f810812a58#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Floor,
"0.32715",
"0x0.53c#10",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Ceiling,
"0.32764",
"0x0.53e#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
10,
Nearest,
"0.32764",
"0x0.53e#10",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Floor,
"0.32745015023725844332253525998813",
"0x0.53d3c5e656dd20ec63b484c7e8#100",
Less,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Ceiling,
"0.32745015023725844332253525998852",
"0x0.53d3c5e656dd20ec63b484c7f0#100",
Greater,
);
test(
"0.33333333333333333333333333333346",
"0x0.55555555555555555555555558#100",
100,
Nearest,
"0.32745015023725844332253525998852",
"0x0.53d3c5e656dd20ec63b484c7f0#100",
Greater,
);
test("2.0", "0x2.0#2", 10, Floor, "1.4434", "0x1.718#10", Less);
test(
"2.0",
"0x2.0#2",
10,
Ceiling,
"1.4453",
"0x1.720#10",
Greater,
);
test("2.0", "0x2.0#2", 10, Nearest, "1.4434", "0x1.718#10", Less);
test(
"2.0",
"0x2.0#2",
100,
Floor,
"1.4436354751788103424932767402724",
"0x1.719218313d0872f8e831837f0#100",
Less,
);
test(
"2.0",
"0x2.0#2",
100,
Ceiling,
"1.4436354751788103424932767402740",
"0x1.719218313d0872f8e831837f2#100",
Greater,
);
test(
"2.0",
"0x2.0#2",
100,
Nearest,
"1.4436354751788103424932767402724",
"0x1.719218313d0872f8e831837f0#100",
Less,
);
test("10.0", "0xa.0#4", 10, Floor, "2.9961", "0x2.ff#10", Less);
test(
"10.0",
"0xa.0#4",
10,
Ceiling,
"3.0000",
"0x3.00#10",
Greater,
);
test(
"10.0",
"0xa.0#4",
10,
Nearest,
"3.0000",
"0x3.00#10",
Greater,
);
test(
"10.0",
"0xa.0#4",
100,
Floor,
"2.9982229502979697388465955375953",
"0x2.ff8b8a0da57b5aa38395e9070#100",
Less,
);
test(
"10.0",
"0xa.0#4",
100,
Ceiling,
"2.9982229502979697388465955375985",
"0x2.ff8b8a0da57b5aa38395e9074#100",
Greater,
);
test(
"10.0",
"0xa.0#4",
100,
Nearest,
"2.9982229502979697388465955375953",
"0x2.ff8b8a0da57b5aa38395e9070#100",
Less,
);
test(
"-100.0",
"-0x64.0#7",
10,
Floor,
"-5.3047",
"-0x5.4e#10",
Less,
);
test(
"-100.0",
"-0x64.0#7",
10,
Ceiling,
"-5.2969",
"-0x5.4c#10",
Greater,
);
test(
"-100.0",
"-0x64.0#7",
10,
Nearest,
"-5.2969",
"-0x5.4c#10",
Greater,
);
test(
"-100.0",
"-0x64.0#7",
100,
Floor,
"-5.2983423656105887573688256891151",
"-0x5.4c602a4f4f0a7cedac9045f40#100",
Less,
);
test(
"-100.0",
"-0x64.0#7",
100,
Ceiling,
"-5.2983423656105887573688256891088",
"-0x5.4c602a4f4f0a7cedac9045f38#100",
Greater,
);
test(
"-100.0",
"-0x64.0#7",
100,
Nearest,
"-5.2983423656105887573688256891151",
"-0x5.4c602a4f4f0a7cedac9045f40#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Floor,
"7.5938",
"0x7.98#10",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Ceiling,
"7.6016",
"0x7.9a#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
10,
Nearest,
"7.6016",
"0x7.9a#10",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Floor,
"7.6009027095419886115232897846635",
"0x7.99d4c28d8f8554d4dd7364140#100",
Less,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Ceiling,
"7.6009027095419886115232897846698",
"0x7.99d4c28d8f8554d4dd7364148#100",
Greater,
);
test(
"1000.0",
"0x3e8.0#10",
100,
Nearest,
"7.6009027095419886115232897846635",
"0x7.99d4c28d8f8554d4dd7364140#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Floor,
"1.8613",
"0x1.dc8#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Ceiling,
"1.8633",
"0x1.dd0#10",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
10,
Nearest,
"1.8613",
"0x1.dc8#10",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Floor,
"1.8622957433108482199035772703700",
"0x1.dcbf69f10006ce973ebb7a636#100",
Less,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Ceiling,
"1.8622957433108482199035772703716",
"0x1.dcbf69f10006ce973ebb7a638#100",
Greater,
);
test(
"3.14159265358979323851",
"0x3.243f6a8885a308d4#64",
100,
Nearest,
"1.8622957433108482199035772703700",
"0x1.dcbf69f10006ce973ebb7a636#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Floor,
"14.500",
"0xe.80#10",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Ceiling,
"14.516",
"0xe.84#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
10,
Nearest,
"14.516",
"0xe.84#10",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Floor,
"14.508657738524469413525180755814",
"0xe.823764bfd1e5fa37c6bf52ed#100",
Less,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Ceiling,
"14.508657738524469413525180755826",
"0xe.823764bfd1e5fa37c6bf52ee#100",
Greater,
);
test(
"1000000.0",
"0xf4240.0#20",
100,
Nearest,
"14.508657738524469413525180755814",
"0xe.823764bfd1e5fa37c6bf52ed#100",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Floor,
"-19.125",
"-0x13.20#10",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Ceiling,
"-19.094",
"-0x13.18#10",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
10,
Nearest,
"-19.125",
"-0x13.20#10",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Floor,
"-19.113827924512310806561163758946",
"-0x13.1d23d3ad26e4fe563fe7f692#100",
Less,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Ceiling,
"-19.113827924512310806561163758921",
"-0x13.1d23d3ad26e4fe563fe7f690#100",
Greater,
);
test(
"-100000000.0",
"-0x5f5e100.0#27",
100,
Nearest,
"-19.113827924512310806561163758921",
"-0x13.1d23d3ad26e4fe563fe7f690#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Floor,
"0.00097561",
"0x0.003ff#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Floor,
"-0.00097656",
"-0x0.00400#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Ceiling,
"0.00097656",
"0x0.00400#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Ceiling,
"-0.00097561",
"-0x0.003ff#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Nearest,
"0.00097656",
"0x0.00400#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Nearest,
"-0.00097656",
"-0x0.00400#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
10,
Down,
"0.00097561",
"0x0.003ff#10",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Down,
"-0.00097561",
"-0x0.003ff#10",
Greater,
);
test(
"0.00098",
"0x0.004#1",
10,
Up,
"0.00097656",
"0x0.00400#10",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
10,
Up,
"-0.00097656",
"-0x0.00400#10",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Floor,
"0.00097656234477963751076391095890807",
"0x0.003fffff55555a2221f46b48a630#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Floor,
"-0.00097656234477963751076391095890884",
"-0x0.003fffff55555a2221f46b48a634#100",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Ceiling,
"0.00097656234477963751076391095890884",
"0x0.003fffff55555a2221f46b48a634#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Ceiling,
"-0.00097656234477963751076391095890807",
"-0x0.003fffff55555a2221f46b48a630#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Nearest,
"0.00097656234477963751076391095890884",
"0x0.003fffff55555a2221f46b48a634#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Nearest,
"-0.00097656234477963751076391095890884",
"-0x0.003fffff55555a2221f46b48a634#100",
Less,
);
test(
"0.00098",
"0x0.004#1",
100,
Down,
"0.00097656234477963751076391095890807",
"0x0.003fffff55555a2221f46b48a630#100",
Less,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Down,
"-0.00097656234477963751076391095890807",
"-0x0.003fffff55555a2221f46b48a630#100",
Greater,
);
test(
"0.00098",
"0x0.004#1",
100,
Up,
"0.00097656234477963751076391095890884",
"0x0.003fffff55555a2221f46b48a634#100",
Greater,
);
test(
"-0.00098",
"-0x0.004#1",
100,
Up,
"-0.00097656234477963751076391095890884",
"-0x0.003fffff55555a2221f46b48a634#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Floor,
"8.8817841970012523233890533447196e-16",
"0x3.ffffffffffffffffffffffffcE-13#100",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Floor,
"-8.8817841970012523233890533447266e-16",
"-0x4.0000000000000000000000000E-13#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Ceiling,
"8.8817841970012523233890533447266e-16",
"0x4.0000000000000000000000000E-13#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Ceiling,
"-8.8817841970012523233890533447196e-16",
"-0x3.ffffffffffffffffffffffffcE-13#100",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Nearest,
"8.8817841970012523233890533447266e-16",
"0x4.0000000000000000000000000E-13#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Nearest,
"-8.8817841970012523233890533447266e-16",
"-0x4.0000000000000000000000000E-13#100",
Less,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Down,
"8.8817841970012523233890533447196e-16",
"0x3.ffffffffffffffffffffffffcE-13#100",
Less,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Down,
"-8.8817841970012523233890533447196e-16",
"-0x3.ffffffffffffffffffffffffcE-13#100",
Greater,
);
test(
"8.9e-16",
"0x4.0E-13#1",
100,
Up,
"8.8817841970012523233890533447266e-16",
"0x4.0000000000000000000000000E-13#100",
Greater,
);
test(
"-8.9e-16",
"-0x4.0E-13#1",
100,
Up,
"-8.8817841970012523233890533447266e-16",
"-0x4.0000000000000000000000000E-13#100",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Floor,
"7.8809e-31",
"0xf.fcE-26#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Floor,
"-7.8886e-31",
"-0x1.000E-25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Ceiling,
"7.8886e-31",
"0x1.000E-25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Ceiling,
"-7.8809e-31",
"-0xf.fcE-26#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Nearest,
"7.8886e-31",
"0x1.000E-25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Nearest,
"-7.8886e-31",
"-0x1.000E-25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Down,
"7.8809e-31",
"0xf.fcE-26#10",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Down,
"-7.8809e-31",
"-0xf.fcE-26#10",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
10,
Up,
"7.8886e-31",
"0x1.000E-25#10",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
10,
Up,
"-7.8886e-31",
"-0x1.000E-25#10",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Floor,
"7.888609052210118054117285652827862296732064351090230047702788488458380783712241150704674\
1677e-31",
"0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Floor,
"-7.88860905221011805411728565282786229673206435109023004770278848845838078371224115070467\
41715e-31",
"-0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555556E-26#300",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Ceiling,
"7.888609052210118054117285652827862296732064351090230047702788488458380783712241150704674\
1715e-31",
"0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555556E-26#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Ceiling,
"-7.88860905221011805411728565282786229673206435109023004770278848845838078371224115070467\
41677e-31",
"-0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Nearest,
"7.888609052210118054117285652827862296732064351090230047702788488458380783712241150704674\
1677e-31",
"0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Nearest,
"-7.88860905221011805411728565282786229673206435109023004770278848845838078371224115070467\
41677e-31",
"-0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Down,
"7.888609052210118054117285652827862296732064351090230047702788488458380783712241150704674\
1677e-31",
"0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Down,
"-7.88860905221011805411728565282786229673206435109023004770278848845838078371224115070467\
41677e-31",
"-0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555555E-26#300",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
300,
Up,
"7.888609052210118054117285652827862296732064351090230047702788488458380783712241150704674\
1715e-31",
"0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555556E-26#300",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
300,
Up,
"-7.88860905221011805411728565282786229673206435109023004770278848845838078371224115070467\
41715e-31",
"-0xf.fffffffffffffffffffffffffffffffffffffffffffffffffd555555555555555555555556E-26#300",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Floor,
"9.0861e-13",
"0xf.fcE-11#10",
Less,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Floor,
"-9.0949e-13",
"-0x1.000E-10#10",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Ceiling,
"9.0949e-13",
"0x1.000E-10#10",
Greater,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Ceiling,
"-9.0861e-13",
"-0xf.fcE-11#10",
Greater,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Nearest,
"9.0949e-13",
"0x1.000E-10#10",
Greater,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Nearest,
"-9.0949e-13",
"-0x1.000E-10#10",
Less,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Down,
"9.0861e-13",
"0xf.fcE-11#10",
Less,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Down,
"-9.0861e-13",
"-0xf.fcE-11#10",
Greater,
);
test(
"9.0949470177292823791503906250000000000000000000000000000000000e-13",
"0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Up,
"9.0949e-13",
"0x1.000E-10#10",
Greater,
);
test(
"-9.0949470177292823791503906250000000000000000000000000000000000e-13",
"-0x1.00000000000000000000000000000000000000000000000000E-10#200",
10,
Up,
"-9.0949e-13",
"-0x1.000E-10#10",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Floor,
"-2.38256490488795107322e-323228497",
"-0x1.0000000000000000E-268435456#64",
Less,
);
test(
"1.0e-301030",
"0x1.0E-250000#1",
64,
Floor,
"1.01003405919803022465e-301030",
"0xf.fffffffffffffffE-250001#64",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Ceiling,
"2.38256490488795107322e-323228497",
"0x1.0000000000000000E-268435456#64",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Ceiling,
"-0.0",
"-0x0.0",
Greater,
);
test(
"1.0e-301030",
"0x1.0E-250000#1",
64,
Ceiling,
"1.01003405919803022470e-301030",
"0x1.0000000000000000E-250000#64",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
64,
Nearest,
"2.38256490488795107322e-323228497",
"0x1.0000000000000000E-268435456#64",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
64,
Nearest,
"-2.38256490488795107322e-323228497",
"-0x1.0000000000000000E-268435456#64",
Less,
);
test(
"1.0e-301030",
"0x1.0E-250000#1",
64,
Nearest,
"1.01003405919803022470e-301030",
"0x1.0000000000000000E-250000#64",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Floor,
"21.031",
"0x15.08#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Ceiling,
"21.062",
"0x15.10#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Nearest,
"21.062",
"0x15.10#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Down,
"21.031",
"0x15.08#10",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
10,
Up,
"21.062",
"0x15.10#10",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Floor,
"21.059738073567624087176720584002",
"0x15.0f4afe904c8a71d974b1f30e#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Ceiling,
"21.059738073567624087176720584027",
"0x15.0f4afe904c8a71d974b1f310#100",
Greater,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Nearest,
"21.059738073567624087176720584002",
"0x15.0f4afe904c8a71d974b1f30e#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Down,
"21.059738073567624087176720584002",
"0x15.0f4afe904c8a71d974b1f30e#100",
Less,
);
test(
"700000000.00",
"0x29b92700.0#30",
100,
Up,
"21.059738073567624087176720584027",
"0x15.0f4afe904c8a71d974b1f310#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Floor,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Ceiling,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Nearest,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Down,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
10,
Up,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Floor,
"21.121049676165439428678979107033",
"0x15.1efd1c90526b838dc390cdf8#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Ceiling,
"21.121049676165439428678979107058",
"0x15.1efd1c90526b838dc390cdfa#100",
Greater,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Nearest,
"21.121049676165439428678979107033",
"0x15.1efd1c90526b838dc390cdf8#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Down,
"21.121049676165439428678979107033",
"0x15.1efd1c90526b838dc390cdf8#100",
Less,
);
test(
"744261117.50",
"0x2c5c85fd.8#31",
100,
Up,
"21.121049676165439428678979107058",
"0x15.1efd1c90526b838dc390cdfa#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Floor,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Ceiling,
"-21.094",
"-0x15.18#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Nearest,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Down,
"-21.094",
"-0x15.18#10",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
10,
Up,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Floor,
"-21.121049676165439428678979107058",
"-0x15.1efd1c90526b838dc390cdfa#100",
Less,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Ceiling,
"-21.121049676165439428678979107033",
"-0x15.1efd1c90526b838dc390cdf8#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Nearest,
"-21.121049676165439428678979107033",
"-0x15.1efd1c90526b838dc390cdf8#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Down,
"-21.121049676165439428678979107033",
"-0x15.1efd1c90526b838dc390cdf8#100",
Greater,
);
test(
"-744261117.50",
"-0x2c5c85fd.8#31",
100,
Up,
"-21.121049676165439428678979107058",
"-0x15.1efd1c90526b838dc390cdfa#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Floor,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Ceiling,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Nearest,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Down,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
10,
Up,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Floor,
"21.121049676703410062207743023070",
"0x15.1efd1c92a1ecc911a3f30740#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Ceiling,
"21.121049676703410062207743023095",
"0x15.1efd1c92a1ecc911a3f30742#100",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Nearest,
"21.121049676703410062207743023095",
"0x15.1efd1c92a1ecc911a3f30742#100",
Greater,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Down,
"21.121049676703410062207743023070",
"0x15.1efd1c92a1ecc911a3f30740#100",
Less,
);
test(
"744261117.90039",
"0x2c5c85fd.e68#40",
100,
Up,
"21.121049676703410062207743023095",
"0x15.1efd1c92a1ecc911a3f30742#100",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Floor,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Ceiling,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Nearest,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Down,
"21.094",
"0x15.18#10",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
10,
Up,
"21.125",
"0x15.20#10",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Floor,
"21.121049676837246658796771995816",
"0x15.1efd1c93351470369d535cce#100",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Ceiling,
"21.121049676837246658796771995841",
"0x15.1efd1c93351470369d535cd0#100",
Greater,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Nearest,
"21.121049676837246658796771995816",
"0x15.1efd1c93351470369d535cce#100",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Down,
"21.121049676837246658796771995816",
"0x15.1efd1c93351470369d535cce#100",
Less,
);
test(
"744261118.00",
"0x2c5c85fe.0#30",
100,
Up,
"21.121049676837246658796771995841",
"0x15.1efd1c93351470369d535cd0#100",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Floor,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Ceiling,
"-21.094",
"-0x15.18#10",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Nearest,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Down,
"-21.094",
"-0x15.18#10",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
10,
Up,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Floor,
"-21.121049676837246658796771995841",
"-0x15.1efd1c93351470369d535cd0#100",
Less,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Ceiling,
"-21.121049676837246658796771995816",
"-0x15.1efd1c93351470369d535cce#100",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Nearest,
"-21.121049676837246658796771995816",
"-0x15.1efd1c93351470369d535cce#100",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Down,
"-21.121049676837246658796771995816",
"-0x15.1efd1c93351470369d535cce#100",
Greater,
);
test(
"-744261118.00",
"-0x2c5c85fe.0#30",
100,
Up,
"-21.121049676837246658796771995841",
"-0x15.1efd1c93351470369d535cd0#100",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
10,
Floor,
"21.406",
"0x15.68#10",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
10,
Ceiling,
"21.438",
"0x15.70#10",
Greater,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
10,
Nearest,
"21.406",
"0x15.68#10",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
10,
Down,
"21.406",
"0x15.68#10",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
10,
Up,
"21.438",
"0x15.70#10",
Greater,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
100,
Floor,
"21.416413017506356465829155213605",
"0x15.6a9a0b23d187ace95ab1462a#100",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
100,
Ceiling,
"21.416413017506356465829155213630",
"0x15.6a9a0b23d187ace95ab1462c#100",
Greater,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
100,
Nearest,
"21.416413017506356465829155213605",
"0x15.6a9a0b23d187ace95ab1462a#100",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
100,
Down,
"21.416413017506356465829155213605",
"0x15.6a9a0b23d187ace95ab1462a#100",
Less,
);
test(
"1000000000.0",
"0x3b9aca00.0#30",
100,
Up,
"21.416413017506356465829155213630",
"0x15.6a9a0b23d187ace95ab1462c#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Floor,
"7.4344e8",
"0x2.c5E+7#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Ceiling,
"7.4449e8",
"0x2.c6E+7#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Nearest,
"7.4449e8",
"0x2.c6E+7#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Down,
"7.4344e8",
"0x2.c5E+7#10",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
10,
Up,
"7.4449e8",
"0x2.c6E+7#10",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Floor,
"744261117.95391597822607658233916",
"0x2c5c85fd.f433d6699ce38ac130#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Ceiling,
"744261117.95391597822607658234001",
"0x2c5c85fd.f433d6699ce38ac134#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Nearest,
"744261117.95391597822607658234001",
"0x2c5c85fd.f433d6699ce38ac134#100",
Greater,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Down,
"744261117.95391597822607658233916",
"0x2c5c85fd.f433d6699ce38ac130#100",
Less,
);
test(
"2.0965e323228496",
"0x7.feE+268435455#10",
100,
Up,
"744261117.95391597822607658234001",
"0x2c5c85fd.f433d6699ce38ac134#100",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Floor,
"-7.4449e8",
"-0x2.c6E+7#10",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Ceiling,
"-7.4344e8",
"-0x2.c5E+7#10",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Nearest,
"-7.4449e8",
"-0x2.c6E+7#10",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Down,
"-7.4344e8",
"-0x2.c5E+7#10",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
10,
Up,
"-7.4449e8",
"-0x2.c6E+7#10",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Floor,
"-744261117.95391597822607658234001",
"-0x2c5c85fd.f433d6699ce38ac134#100",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Ceiling,
"-744261117.95391597822607658233916",
"-0x2c5c85fd.f433d6699ce38ac130#100",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Nearest,
"-744261117.95391597822607658234001",
"-0x2c5c85fd.f433d6699ce38ac134#100",
Less,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Down,
"-744261117.95391597822607658233916",
"-0x2c5c85fd.f433d6699ce38ac130#100",
Greater,
);
test(
"-2.0965e323228496",
"-0x7.feE+268435455#10",
100,
Up,
"-744261117.95391597822607658234001",
"-0x2c5c85fd.f433d6699ce38ac134#100",
Less,
);
test(
"744261117.29980",
"0x2c5c85fd.4cc#40",
105,
Floor,
"21.1210496758964541118060674980227",
"0x15.1efd1c8f2aaae0c9d2db6539a#105",
Less,
);
test(
"744261117.29980",
"0x2c5c85fd.4cc#40",
105,
Ceiling,
"21.1210496758964541118060674980235",
"0x15.1efd1c8f2aaae0c9d2db6539b#105",
Greater,
);
test(
"744261117.29980",
"0x2c5c85fd.4cc#40",
105,
Nearest,
"21.1210496758964541118060674980227",
"0x15.1efd1c8f2aaae0c9d2db6539a#105",
Less,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
1,
Floor,
"2.7e8",
"0x1.0E+7#1",
Less,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
1,
Ceiling,
"5.4e8",
"0x2.0E+7#1",
Greater,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
1,
Nearest,
"2.7e8",
"0x1.0E+7#1",
Less,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
10,
Floor,
"3.7172e8",
"0x1.628E+7#10",
Less,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
10,
Ceiling,
"3.7224e8",
"0x1.630E+7#10",
Greater,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
10,
Nearest,
"3.7224e8",
"0x1.630E+7#10",
Greater,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
100,
Floor,
"372130558.28429932837700628814559",
"0x162e42fe.48c7d73da76cfcc736#100",
Less,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
100,
Ceiling,
"372130558.28429932837700628814601",
"0x162e42fe.48c7d73da76cfcc738#100",
Greater,
);
test(
"5.1e161614247",
"0x4.0E+134217727#1",
100,
Nearest,
"372130558.28429932837700628814559",
"0x162e42fe.48c7d73da76cfcc736#100",
Less,
);
test(
"1.016e161614248",
"0x7.fE+134217727#7",
20,
Down,
"3.7213030e8",
"0x1.62e42E+7#20",
Less,
);
test(
"1.016e161614248",
"0x7.fE+134217727#7",
20,
Up,
"3.7213082e8",
"0x1.62e44E+7#20",
Greater,
);
test(
"1.016e161614248",
"0x7.fE+134217727#7",
20,
Nearest,
"3.7213030e8",
"0x1.62e42E+7#20",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
1,
Floor,
"2.7e8",
"0x1.0E+7#1",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
1,
Ceiling,
"5.4e8",
"0x2.0E+7#1",
Greater,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
1,
Nearest,
"2.7e8",
"0x1.0E+7#1",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
10,
Floor,
"3.7172e8",
"0x1.628E+7#10",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
10,
Ceiling,
"3.7224e8",
"0x1.630E+7#10",
Greater,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
10,
Nearest,
"3.7224e8",
"0x1.630E+7#10",
Greater,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
100,
Floor,
"372130558.97744650893695159756284",
"0x162e42fe.fa39ef35793c767300#100",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
100,
Ceiling,
"372130558.97744650893695159756327",
"0x162e42fe.fa39ef35793c767302#100",
Greater,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
100,
Nearest,
"372130558.97744650893695159756284",
"0x162e42fe.fa39ef35793c767300#100",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
200,
Floor,
"372130558.97744650893695159756294602395972384199011277483256122",
"0x162e42fe.fa39ef35793c7673007e5ed5e81e6864ce5316c5b14#200",
Less,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
200,
Ceiling,
"372130558.97744650893695159756294602395972384199011277483256155",
"0x162e42fe.fa39ef35793c7673007e5ed5e81e6864ce5316c5b16#200",
Greater,
);
test(
"1.0e161614248",
"0x8.0E+134217727#1",
200,
Nearest,
"372130558.97744650893695159756294602395972384199011277483256122",
"0x162e42fe.fa39ef35793c7673007e5ed5e81e6864ce5316c5b14#200",
Less,
);
test(
"-1.0e161614248",
"-0x8.0E+134217727#1",
64,
Floor,
"-372130558.977446508943",
"-0x162e42fe.fa39ef358#64",
Less,
);
test(
"-1.0e161614248",
"-0x8.0E+134217727#1",
64,
Ceiling,
"-372130558.977446508914",
"-0x162e42fe.fa39ef356#64",
Greater,
);
test(
"-1.0e161614248",
"-0x8.0E+134217727#1",
64,
Down,
"-372130558.977446508914",
"-0x162e42fe.fa39ef356#64",
Greater,
);
test(
"-1.0e161614248",
"-0x8.0E+134217727#1",
64,
Up,
"-372130558.977446508943",
"-0x162e42fe.fa39ef358#64",
Less,
);
test(
"-1.0e161614248",
"-0x8.0E+134217727#1",
64,
Nearest,
"-372130558.977446508943",
"-0x162e42fe.fa39ef358#64",
Less,
);
test(
"2.041e161614248",
"0xf.fE+134217727#8",
30,
Floor,
"372130559.50",
"0x162e42ff.8#30",
Less,
);
test(
"2.041e161614248",
"0xf.fE+134217727#8",
30,
Nearest,
"372130559.50",
"0x162e42ff.8#30",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
1,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
1,
Nearest,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
100,
Floor,
"0.0",
"0x0.0",
Less,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
100,
Ceiling,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"2.4e-323228497",
"0x1.0E-268435456#1",
100,
Nearest,
"2.3825649048879510732161697817327e-323228497",
"0x1.0000000000000000000000000E-268435456#100",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Floor,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Ceiling,
"-0.0",
"-0x0.0",
Greater,
);
test(
"-2.4e-323228497",
"-0x1.0E-268435456#1",
10,
Nearest,
"-2.3826e-323228497",
"-0x1.000E-268435456#10",
Less,
);
test(
"4.656612873077392580113e-10",
"0x2.000000000000000fcE-8#68",
25,
Nearest,
"4.65661287e-10",
"0x2.000000E-8#25",
Less,
);
test(
"4.656612873077392580113e-10",
"0x2.000000000000000fcE-8#68",
25,
Floor,
"4.65661287e-10",
"0x2.000000E-8#25",
Less,
);
test(
"4.656612873077392580113e-10",
"0x2.000000000000000fcE-8#68",
25,
Ceiling,
"4.65661315e-10",
"0x2.000002E-8#25",
Greater,
);
test(
"4.6938657760620117187500306e-7",
"0x7.e000000000000000003eE-6#82",
7,
Nearest,
"4.694e-7",
"0x7.eE-6#7",
Greater,
);
}
#[test]
#[should_panic]
fn asinh_prec_round_fail() {
Float::ONE.asinh_prec_round(0, Nearest);
}
#[test]
#[should_panic]
fn asinh_prec_round_exact_fail() {
Float::ONE.asinh_prec_round(10, Exact);
}
#[test]
#[should_panic]
fn asinh_prec_fail() {
Float::ONE.asinh_prec(0);
}
#[test]
#[should_panic]
fn asinh_round_fail() {
Float::ONE.asinh_round(Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn asinh_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {
let (c, o) = x.clone().asinh_prec_round(prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.asinh_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.asinh_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_asinh_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).asinh_prec_round(prec, -rm);
assert_eq!(ComparableFloatRef(&c_neg), ComparableFloatRef(&-&c));
assert_eq!(o_neg, o.reverse());
if !x.is_nan() {
assert!(c.le_abs(&x) || c.get_prec() < x.get_prec());
assert_eq!(c.is_sign_positive(), x.is_sign_positive());
}
if c.is_normal() {
assert_eq!(c.get_prec(), Some(prec));
}
if o == Equal {
for rm2 in exhaustive_rounding_modes() {
let (c2, o2) = x.asinh_prec_round_ref(prec, rm2);
assert_eq!(ComparableFloat(c2), ComparableFloat(c.clone()));
assert_eq!(o2, Equal);
}
} else {
assert_panic!(x.asinh_prec_round_ref(prec, Exact));
}
}
#[test]
fn asinh_prec_round_properties() {
float_unsigned_rounding_mode_triple_gen_var_36().test_properties(|(x, prec, rm)| {
asinh_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::NAN.asinh_prec_round(prec, rm);
assert!(c.is_nan());
assert_eq!(o, Equal);
let (c, o) = Float::INFINITY.asinh_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::INFINITY));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_INFINITY.asinh_prec_round(prec, rm);
assert_eq!(
ComparableFloat(c),
ComparableFloat(Float::NEGATIVE_INFINITY)
);
assert_eq!(o, Equal);
let (c, o) = Float::ZERO.asinh_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::ZERO));
assert_eq!(o, Equal);
let (c, o) = Float::NEGATIVE_ZERO.asinh_prec_round(prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::NEGATIVE_ZERO));
assert_eq!(o, Equal);
});
}
#[test]
fn asinh_round_properties() {
float_rounding_mode_pair_gen_var_47().test_properties(|(x, rm)| {
let (c, o) = x.clone().asinh_round(rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = x.asinh_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.asinh_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.asinh_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_asinh_round(&rug::Float::exact_from(&x), rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
}
});
}
#[test]
fn asinh_prec_properties() {
float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {
let (c, o) = x.clone().asinh_prec(prec);
assert!(c.is_valid());
let (c_alt, o_alt) = x.asinh_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.asinh_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.asinh_prec_round_ref(prec, Nearest);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
let (rug_c, rug_o) = rug_asinh_prec(&rug::Float::exact_from(&x), prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
});
}
#[test]
fn asinh_properties() {
float_gen().test_properties(|x| {
let c = x.clone().asinh();
assert!(c.is_valid());
let c_alt = (&x).asinh();
assert!(c_alt.is_valid());
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
let mut x_alt = x.clone();
x_alt.asinh_assign();
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&c));
let c_alt = x.asinh_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_asinh(
&rug::Float::exact_from(&x)
))),
ComparableFloatRef(&c)
);
assert_eq!(ComparableFloatRef(&(-&x).asinh()), 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_asinh() {
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_asinh(x)), NiceFloat(out));
}
test::<f32>(f32::NAN, f32::NAN);
test::<f32>(f32::INFINITY, f32::INFINITY);
test::<f32>(f32::NEGATIVE_INFINITY, f32::NEGATIVE_INFINITY);
test::<f32>(0.0, 0.0);
test::<f32>(-0.0, -0.0);
test::<f32>(1.0, 0.8813736);
test::<f32>(-1.0, -0.8813736);
test::<f32>(0.5, 0.4812118);
test::<f32>(-0.5, -0.4812118);
test::<f32>(2.0, 1.4436355);
test::<f32>(10.0, 2.998223);
test::<f32>(core::f32::consts::PI, 1.8622957);
test::<f32>(88.0, 5.1705165);
test::<f32>(10000000000.0, 23.718998);
test::<f32>(1.0e30, 69.7707);
test::<f32>(3.4028235e38, 89.415985);
test::<f32>(-3.4028235e38, -89.415985);
test::<f32>(1.0e-20, 1.0e-20);
test::<f32>(1.0e-45, 1.0e-45);
test::<f32>(-1.0e-45, -1.0e-45);
test::<f64>(f64::NAN, f64::NAN);
test::<f64>(f64::INFINITY, f64::INFINITY);
test::<f64>(f64::NEGATIVE_INFINITY, f64::NEGATIVE_INFINITY);
test::<f64>(0.0, 0.0);
test::<f64>(-0.0, -0.0);
test::<f64>(1.0, 0.881373587019543);
test::<f64>(-1.0, -0.881373587019543);
test::<f64>(0.5, 0.48121182505960347);
test::<f64>(-0.5, -0.48121182505960347);
test::<f64>(2.0, 1.4436354751788103);
test::<f64>(10.0, 2.99822295029797);
test::<f64>(core::f64::consts::PI, 1.8622957433108482);
test::<f64>(709.0, 7.257003204425001);
test::<f64>(1.0e100, 230.95165647996453);
test::<f64>(1.0e300, 691.4686750787737);
test::<f64>(1.7976931348623157e308, 710.475860073944);
test::<f64>(-1.7976931348623157e308, -710.475860073944);
test::<f64>(1.0e-200, 1.0e-200);
test::<f64>(5.0e-324, 5.0e-324);
test::<f64>(-5.0e-324, -5.0e-324);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_asinh_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_asinh(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.abs() <= x.abs());
assert_eq!(NiceFloat(primitive_float_asinh(-x)), NiceFloat(-c));
}
if x.is_finite() {
let rug_x = rug::Float::with_val(
u32::exact_from(T::MANTISSA_WIDTH + 1),
&rug::Float::exact_from(&Float::from(x)),
);
let rug_c = <Float as From<&rug::Float>>::from(&rug_x.asinh());
let expected = T::exact_from(&rug_c);
assert_eq!(NiceFloat(expected), NiceFloat(c));
}
});
}
#[test]
fn primitive_float_asinh_properties() {
apply_fn_to_primitive_floats!(primitive_float_asinh_properties_helper);
}
#[test]
fn test_asinh_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::asinh_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::asinh_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_asinh_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, "0.0", "0x0.0", Equal);
test("0", 10, Down, "0.0", "0x0.0", Equal);
test("0", 1, Up, "0.0", "0x0.0", Equal);
test("0", 10, Up, "0.0", "0x0.0", Equal);
test("0", 1, Floor, "0.0", "0x0.0", Equal);
test("0", 10, Floor, "0.0", "0x0.0", Equal);
test("0", 1, Ceiling, "0.0", "0x0.0", Equal);
test("0", 10, Ceiling, "0.0", "0x0.0", Equal);
test("0", 1, Nearest, "0.0", "0x0.0", Equal);
test("0", 10, Nearest, "0.0", "0x0.0", Equal);
test("0", 1, Exact, "0.0", "0x0.0", Equal);
test("0", 10, Exact, "0.0", "0x0.0", Equal);
test("3/5", 1, Floor, "0.50", "0x0.8#1", Less);
test("3/5", 1, Ceiling, "1.0", "0x1.0#1", Greater);
test("3/5", 1, Nearest, "0.50", "0x0.8#1", Less);
test("3/5", 10, Floor, "0.56836", "0x0.918#10", Less);
test("3/5", 10, Ceiling, "0.56934", "0x0.91c#10", Greater);
test("3/5", 10, Nearest, "0.56836", "0x0.918#10", Less);
test(
"3/5",
100,
Floor,
"0.56882489873224753009868833686101",
"0x0.919e8231349ca195eef163017#100",
Less,
);
test(
"3/5",
100,
Ceiling,
"0.56882489873224753009868833686180",
"0x0.919e8231349ca195eef163018#100",
Greater,
);
test(
"3/5",
100,
Nearest,
"0.56882489873224753009868833686101",
"0x0.919e8231349ca195eef163017#100",
Less,
);
test("-3/5", 1, Floor, "-1.0", "-0x1.0#1", Less);
test("-3/5", 1, Ceiling, "-0.50", "-0x0.8#1", Greater);
test("-3/5", 1, Nearest, "-0.50", "-0x0.8#1", Greater);
test("-3/5", 10, Floor, "-0.56934", "-0x0.91c#10", Less);
test("-3/5", 10, Ceiling, "-0.56836", "-0x0.918#10", Greater);
test("-3/5", 10, Nearest, "-0.56836", "-0x0.918#10", Greater);
test(
"-3/5",
100,
Floor,
"-0.56882489873224753009868833686180",
"-0x0.919e8231349ca195eef163018#100",
Less,
);
test(
"-3/5",
100,
Ceiling,
"-0.56882489873224753009868833686101",
"-0x0.919e8231349ca195eef163017#100",
Greater,
);
test(
"-3/5",
100,
Nearest,
"-0.56882489873224753009868833686101",
"-0x0.919e8231349ca195eef163017#100",
Greater,
);
test("1/3", 1, Floor, "0.25", "0x0.4#1", Less);
test("1/3", 1, Ceiling, "0.50", "0x0.8#1", Greater);
test("1/3", 1, Nearest, "0.25", "0x0.4#1", Less);
test("1/3", 10, Floor, "0.32715", "0x0.53c#10", Less);
test("1/3", 10, Ceiling, "0.32764", "0x0.53e#10", Greater);
test("1/3", 10, Nearest, "0.32764", "0x0.53e#10", Greater);
test(
"1/3",
100,
Floor,
"0.32745015023725844332253525998813",
"0x0.53d3c5e656dd20ec63b484c7e8#100",
Less,
);
test(
"1/3",
100,
Ceiling,
"0.32745015023725844332253525998852",
"0x0.53d3c5e656dd20ec63b484c7f0#100",
Greater,
);
test(
"1/3",
100,
Nearest,
"0.32745015023725844332253525998813",
"0x0.53d3c5e656dd20ec63b484c7e8#100",
Less,
);
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, "2.0", "0x2.0#1", Greater);
test("22/7", 10, Floor, "1.8613", "0x1.dc8#10", Less);
test("22/7", 10, Ceiling, "1.8633", "0x1.dd0#10", Greater);
test("22/7", 10, Nearest, "1.8633", "0x1.dd0#10", Greater);
test(
"22/7",
100,
Floor,
"1.8626792111346099850190014829486",
"0x1.dcd88b76c3216f8eaa82640e4#100",
Less,
);
test(
"22/7",
100,
Ceiling,
"1.8626792111346099850190014829502",
"0x1.dcd88b76c3216f8eaa82640e6#100",
Greater,
);
test(
"22/7",
100,
Nearest,
"1.8626792111346099850190014829502",
"0x1.dcd88b76c3216f8eaa82640e6#100",
Greater,
);
test("-22/7", 1, Floor, "-2.0", "-0x2.0#1", Less);
test("-22/7", 1, Ceiling, "-1.0", "-0x1.0#1", Greater);
test("-22/7", 1, Nearest, "-2.0", "-0x2.0#1", Less);
test("-22/7", 10, Floor, "-1.8633", "-0x1.dd0#10", Less);
test("-22/7", 10, Ceiling, "-1.8613", "-0x1.dc8#10", Greater);
test("-22/7", 10, Nearest, "-1.8633", "-0x1.dd0#10", Less);
test(
"-22/7",
100,
Floor,
"-1.8626792111346099850190014829502",
"-0x1.dcd88b76c3216f8eaa82640e6#100",
Less,
);
test(
"-22/7",
100,
Ceiling,
"-1.8626792111346099850190014829486",
"-0x1.dcd88b76c3216f8eaa82640e4#100",
Greater,
);
test(
"-22/7",
100,
Nearest,
"-1.8626792111346099850190014829502",
"-0x1.dcd88b76c3216f8eaa82640e6#100",
Less,
);
test("100", 1, Floor, "4.0", "0x4.0#1", Less);
test("100", 1, Ceiling, "8.0", "0x8.0#1", Greater);
test("100", 1, Nearest, "4.0", "0x4.0#1", Less);
test("100", 10, Floor, "5.2969", "0x5.4c#10", Less);
test("100", 10, Ceiling, "5.3047", "0x5.4e#10", Greater);
test("100", 10, Nearest, "5.2969", "0x5.4c#10", Less);
test(
"100",
100,
Floor,
"5.2983423656105887573688256891088",
"0x5.4c602a4f4f0a7cedac9045f38#100",
Less,
);
test(
"100",
100,
Ceiling,
"5.2983423656105887573688256891151",
"0x5.4c602a4f4f0a7cedac9045f40#100",
Greater,
);
test(
"100",
100,
Nearest,
"5.2983423656105887573688256891151",
"0x5.4c602a4f4f0a7cedac9045f40#100",
Greater,
);
test("-100", 1, Floor, "-8.0", "-0x8.0#1", Less);
test("-100", 1, Ceiling, "-4.0", "-0x4.0#1", Greater);
test("-100", 1, Nearest, "-4.0", "-0x4.0#1", Greater);
test("-100", 10, Floor, "-5.3047", "-0x5.4e#10", Less);
test("-100", 10, Ceiling, "-5.2969", "-0x5.4c#10", Greater);
test("-100", 10, Nearest, "-5.2969", "-0x5.4c#10", Greater);
test(
"-100",
100,
Floor,
"-5.2983423656105887573688256891151",
"-0x5.4c602a4f4f0a7cedac9045f40#100",
Less,
);
test(
"-100",
100,
Ceiling,
"-5.2983423656105887573688256891088",
"-0x5.4c602a4f4f0a7cedac9045f38#100",
Greater,
);
test(
"-100",
100,
Nearest,
"-5.2983423656105887573688256891151",
"-0x5.4c602a4f4f0a7cedac9045f40#100",
Less,
);
test("1/1000", 1, Floor, "0.00098", "0x0.004#1", Less);
test("1/1000", 1, Ceiling, "0.0020", "0x0.008#1", Greater);
test("1/1000", 1, Nearest, "0.00098", "0x0.004#1", Less);
test("1/1000", 10, Floor, "0.00099945", "0x0.00418#10", Less);
test("1/1000", 10, Ceiling, "0.0010014", "0x0.0041a#10", Greater);
test("1/1000", 10, Nearest, "0.00099945", "0x0.00418#10", Less);
test(
"1/1000",
100,
Floor,
"0.00099999983333340833328869050657113",
"0x0.0041893694862e5580b27b401a80#100",
Less,
);
test(
"1/1000",
100,
Ceiling,
"0.00099999983333340833328869050657267",
"0x0.0041893694862e5580b27b401a88#100",
Greater,
);
test(
"1/1000",
100,
Nearest,
"0.00099999983333340833328869050657267",
"0x0.0041893694862e5580b27b401a88#100",
Greater,
);
test("-1/1000000", 1, Floor, "-1.9e-6", "-0x0.00002#1", Less);
test("-1/1000000", 1, Ceiling, "-9.5e-7", "-0x0.00001#1", Greater);
test("-1/1000000", 1, Nearest, "-9.5e-7", "-0x0.00001#1", Greater);
test(
"-1/1000000",
10,
Floor,
"-1.0002e-6",
"-0x0.000010c8#10",
Less,
);
test(
"-1/1000000",
10,
Ceiling,
"-9.9838e-7",
"-0x0.000010c0#10",
Greater,
);
test(
"-1/1000000",
10,
Nearest,
"-1.0002e-6",
"-0x0.000010c8#10",
Less,
);
test(
"-1/1000000",
100,
Floor,
"-9.9999999999983333333333340833361e-7",
"-0x0.000010c6f7a0b5ea7a2711cf94320a#100",
Less,
);
test(
"-1/1000000",
100,
Ceiling,
"-9.9999999999983333333333340833211e-7",
"-0x0.000010c6f7a0b5ea7a2711cf943208#100",
Greater,
);
test(
"-1/1000000",
100,
Nearest,
"-9.9999999999983333333333340833361e-7",
"-0x0.000010c6f7a0b5ea7a2711cf94320a#100",
Less,
);
test(
"1/100000000000000000000",
1,
Floor,
"6.8e-21",
"0x2.0E-17#1",
Less,
);
test(
"1/100000000000000000000",
1,
Ceiling,
"1.4e-20",
"0x4.0E-17#1",
Greater,
);
test(
"1/100000000000000000000",
1,
Nearest,
"6.8e-21",
"0x2.0E-17#1",
Less,
);
test(
"1/100000000000000000000",
10,
Floor,
"9.9923e-21",
"0x2.f3E-17#10",
Less,
);
test(
"1/100000000000000000000",
10,
Ceiling,
"1.0006e-20",
"0x2.f4E-17#10",
Greater,
);
test(
"1/100000000000000000000",
10,
Nearest,
"1.0006e-20",
"0x2.f4E-17#10",
Greater,
);
test(
"1/100000000000000000000",
100,
Floor,
"9.9999999999999999999999999999955e-21",
"0x2.f394219248446baa23d2ec728E-17#100",
Less,
);
test(
"1/100000000000000000000",
100,
Ceiling,
"1.0000000000000000000000000000006e-20",
"0x2.f394219248446baa23d2ec72cE-17#100",
Greater,
);
test(
"1/100000000000000000000",
100,
Nearest,
"9.9999999999999999999999999999955e-21",
"0x2.f394219248446baa23d2ec728E-17#100",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Floor,
"-3.2e-30",
"-0x4.0E-25#1",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Ceiling,
"-1.6e-30",
"-0x2.0E-25#1",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
1,
Nearest,
"-3.2e-30",
"-0x4.0E-25#1",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Floor,
"-2.3697e-30",
"-0x3.01E-25#10",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Ceiling,
"-2.3666e-30",
"-0x3.00E-25#10",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
10,
Nearest,
"-2.3666e-30",
"-0x3.00E-25#10",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Floor,
"-2.3665827156630354162351856958508e-30",
"-0x3.0000000000000000000000004E-25#100",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Ceiling,
"-2.3665827156630354162351856958484e-30",
"-0x3.0000000000000000000000000E-25#100",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Nearest,
"-2.3665827156630354162351856958484e-30",
"-0x3.0000000000000000000000000E-25#100",
Greater,
);
test("1488522235/2", 1, Floor, "16.0", "0x1.0E+1#1", Less);
test("1488522235/2", 1, Ceiling, "32.0", "0x2.0E+1#1", Greater);
test("1488522235/2", 1, Nearest, "16.0", "0x1.0E+1#1", Less);
test("1488522235/2", 10, Floor, "21.094", "0x15.18#10", Less);
test("1488522235/2", 10, Ceiling, "21.125", "0x15.20#10", Greater);
test("1488522235/2", 10, Nearest, "21.125", "0x15.20#10", Greater);
test(
"1488522235/2",
100,
Floor,
"21.121049676165439428678979107033",
"0x15.1efd1c90526b838dc390cdf8#100",
Less,
);
test(
"1488522235/2",
100,
Ceiling,
"21.121049676165439428678979107058",
"0x15.1efd1c90526b838dc390cdfa#100",
Greater,
);
test(
"1488522235/2",
100,
Nearest,
"21.121049676165439428678979107033",
"0x15.1efd1c90526b838dc390cdf8#100",
Less,
);
test("7442611177/10", 1, Floor, "16.0", "0x1.0E+1#1", Less);
test("7442611177/10", 1, Ceiling, "32.0", "0x2.0E+1#1", Greater);
test("7442611177/10", 1, Nearest, "16.0", "0x1.0E+1#1", Less);
test("7442611177/10", 10, Floor, "21.094", "0x15.18#10", Less);
test(
"7442611177/10",
10,
Ceiling,
"21.125",
"0x15.20#10",
Greater,
);
test(
"7442611177/10",
10,
Nearest,
"21.125",
"0x15.20#10",
Greater,
);
test(
"7442611177/10",
100,
Floor,
"21.121049676434162320780255257063",
"0x15.1efd1c9179e2489f1a6da274#100",
Less,
);
test(
"7442611177/10",
100,
Ceiling,
"21.121049676434162320780255257088",
"0x15.1efd1c9179e2489f1a6da276#100",
Greater,
);
test(
"7442611177/10",
100,
Nearest,
"21.121049676434162320780255257088",
"0x15.1efd1c9179e2489f1a6da276#100",
Greater,
);
test("-7442611177/10", 1, Floor, "-32.0", "-0x2.0E+1#1", Less);
test(
"-7442611177/10",
1,
Ceiling,
"-16.0",
"-0x1.0E+1#1",
Greater,
);
test(
"-7442611177/10",
1,
Nearest,
"-16.0",
"-0x1.0E+1#1",
Greater,
);
test("-7442611177/10", 10, Floor, "-21.125", "-0x15.20#10", Less);
test(
"-7442611177/10",
10,
Ceiling,
"-21.094",
"-0x15.18#10",
Greater,
);
test(
"-7442611177/10",
10,
Nearest,
"-21.125",
"-0x15.20#10",
Less,
);
test(
"-7442611177/10",
100,
Floor,
"-21.121049676434162320780255257088",
"-0x15.1efd1c9179e2489f1a6da276#100",
Less,
);
test(
"-7442611177/10",
100,
Ceiling,
"-21.121049676434162320780255257063",
"-0x15.1efd1c9179e2489f1a6da274#100",
Greater,
);
test(
"-7442611177/10",
100,
Nearest,
"-21.121049676434162320780255257088",
"-0x15.1efd1c9179e2489f1a6da276#100",
Less,
);
test("744261118", 1, Floor, "16.0", "0x1.0E+1#1", Less);
test("744261118", 1, Ceiling, "32.0", "0x2.0E+1#1", Greater);
test("744261118", 1, Nearest, "16.0", "0x1.0E+1#1", Less);
test("744261118", 10, Floor, "21.094", "0x15.18#10", Less);
test("744261118", 10, Ceiling, "21.125", "0x15.20#10", Greater);
test("744261118", 10, Nearest, "21.125", "0x15.20#10", Greater);
test(
"744261118",
100,
Floor,
"21.121049676837246658796771995816",
"0x15.1efd1c93351470369d535cce#100",
Less,
);
test(
"744261118",
100,
Ceiling,
"21.121049676837246658796771995841",
"0x15.1efd1c93351470369d535cd0#100",
Greater,
);
test(
"744261118",
100,
Nearest,
"21.121049676837246658796771995816",
"0x15.1efd1c93351470369d535cce#100",
Less,
);
test("-744261118", 1, Floor, "-32.0", "-0x2.0E+1#1", Less);
test("-744261118", 1, Ceiling, "-16.0", "-0x1.0E+1#1", Greater);
test("-744261118", 1, Nearest, "-16.0", "-0x1.0E+1#1", Greater);
test("-744261118", 10, Floor, "-21.125", "-0x15.20#10", Less);
test("-744261118", 10, Ceiling, "-21.094", "-0x15.18#10", Greater);
test("-744261118", 10, Nearest, "-21.125", "-0x15.20#10", Less);
test(
"-744261118",
100,
Floor,
"-21.121049676837246658796771995841",
"-0x15.1efd1c93351470369d535cd0#100",
Less,
);
test(
"-744261118",
100,
Ceiling,
"-21.121049676837246658796771995816",
"-0x15.1efd1c93351470369d535cce#100",
Greater,
);
test(
"-744261118",
100,
Nearest,
"-21.121049676837246658796771995816",
"-0x15.1efd1c93351470369d535cce#100",
Greater,
);
test("10000000000", 1, Floor, "16.0", "0x1.0E+1#1", Less);
test("10000000000", 1, Ceiling, "32.0", "0x2.0E+1#1", Greater);
test("10000000000", 1, Nearest, "16.0", "0x1.0E+1#1", Less);
test("10000000000", 10, Floor, "23.719", "0x17.b8#10", Less);
test("10000000000", 10, Ceiling, "23.750", "0x17.c0#10", Greater);
test("10000000000", 10, Nearest, "23.719", "0x17.b8#10", Less);
test(
"10000000000",
100,
Floor,
"23.718998110500402149599646668292",
"0x17.b810429a7c2a5d4073437aea#100",
Less,
);
test(
"10000000000",
100,
Ceiling,
"23.718998110500402149599646668318",
"0x17.b810429a7c2a5d4073437aec#100",
Greater,
);
test(
"10000000000",
100,
Nearest,
"23.718998110500402149599646668292",
"0x17.b810429a7c2a5d4073437aea#100",
Less,
);
test(
"1/1000",
100,
Down,
"0.00099999983333340833328869050657113",
"0x0.0041893694862e5580b27b401a80#100",
Less,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Down,
"-2.3665827156630354162351856958484e-30",
"-0x3.0000000000000000000000000E-25#100",
Greater,
);
test(
"1/1000",
100,
Up,
"0.00099999983333340833328869050657267",
"0x0.0041893694862e5580b27b401a88#100",
Greater,
);
test(
"-108086391056891904/45671926166590716193865151022383844364247891967",
100,
Up,
"-2.3665827156630354162351856958508e-30",
"-0x3.0000000000000000000000004E-25#100",
Less,
);
test("1/65537", 2, Floor, "0.000011", "0x0.0000c#2", Less);
test("1/65537", 2, Ceiling, "0.000015", "0x0.00010#2", Greater);
test("1/65537", 2, Nearest, "0.000015", "0x0.00010#2", Greater);
test("8/4194311", 2, Up, "1.9e-6", "0x0.00002#2", Greater);
test("-8/4194311", 2, Up, "-1.9e-6", "-0x0.00002#2", Less);
test("-1/3", 1, Floor, "-0.50", "-0x0.8#1", Less);
test("-1/3", 1, Ceiling, "-0.25", "-0x0.4#1", Greater);
test("-1/3", 1, Nearest, "-0.25", "-0x0.4#1", Greater);
test("-1/3", 10, Floor, "-0.32764", "-0x0.53e#10", Less);
test("-1/3", 10, Ceiling, "-0.32715", "-0x0.53c#10", Greater);
test("-1/3", 10, Nearest, "-0.32764", "-0x0.53e#10", Less);
test(
"-1/3",
100,
Floor,
"-0.32745015023725844332253525998852",
"-0x0.53d3c5e656dd20ec63b484c7f0#100",
Less,
);
test(
"-1/3",
100,
Ceiling,
"-0.32745015023725844332253525998813",
"-0x0.53d3c5e656dd20ec63b484c7e8#100",
Greater,
);
test(
"-1/3",
100,
Nearest,
"-0.32745015023725844332253525998813",
"-0x0.53d3c5e656dd20ec63b484c7e8#100",
Greater,
);
test("1/1000000", 1, Floor, "9.5e-7", "0x0.00001#1", Less);
test("1/1000000", 1, Ceiling, "1.9e-6", "0x0.00002#1", Greater);
test("1/1000000", 1, Nearest, "9.5e-7", "0x0.00001#1", Less);
test("1/1000000", 10, Floor, "9.9838e-7", "0x0.000010c0#10", Less);
test(
"1/1000000",
10,
Ceiling,
"1.0002e-6",
"0x0.000010c8#10",
Greater,
);
test(
"1/1000000",
10,
Nearest,
"1.0002e-6",
"0x0.000010c8#10",
Greater,
);
test(
"1/1000000",
100,
Floor,
"9.9999999999983333333333340833211e-7",
"0x0.000010c6f7a0b5ea7a2711cf943208#100",
Less,
);
test(
"1/1000000",
100,
Ceiling,
"9.9999999999983333333333340833361e-7",
"0x0.000010c6f7a0b5ea7a2711cf94320a#100",
Greater,
);
test(
"1/1000000",
100,
Nearest,
"9.9999999999983333333333340833361e-7",
"0x0.000010c6f7a0b5ea7a2711cf94320a#100",
Greater,
);
test("1000000", 1, Floor, "8.0", "0x8.0#1", Less);
test("1000000", 1, Ceiling, "16.0", "0x1.0E+1#1", Greater);
test("1000000", 1, Nearest, "16.0", "0x1.0E+1#1", Greater);
test("1000000", 10, Floor, "14.500", "0xe.80#10", Less);
test("1000000", 10, Ceiling, "14.516", "0xe.84#10", Greater);
test("1000000", 10, Nearest, "14.516", "0xe.84#10", Greater);
test(
"1000000",
100,
Floor,
"14.508657738524469413525180755814",
"0xe.823764bfd1e5fa37c6bf52ed#100",
Less,
);
test(
"1000000",
100,
Ceiling,
"14.508657738524469413525180755826",
"0xe.823764bfd1e5fa37c6bf52ee#100",
Greater,
);
test(
"1000000",
100,
Nearest,
"14.508657738524469413525180755814",
"0xe.823764bfd1e5fa37c6bf52ed#100",
Less,
);
test(
"10000000000000000000000000000000000000000",
1,
Floor,
"64.0",
"0x4.0E+1#1",
Less,
);
test(
"10000000000000000000000000000000000000000",
1,
Ceiling,
"1.3e2",
"0x8.0E+1#1",
Greater,
);
test(
"10000000000000000000000000000000000000000",
1,
Nearest,
"64.0",
"0x4.0E+1#1",
Less,
);
test(
"10000000000000000000000000000000000000000",
10,
Floor,
"92.750",
"0x5c.c#10",
Less,
);
test(
"10000000000000000000000000000000000000000",
10,
Ceiling,
"92.875",
"0x5c.e#10",
Greater,
);
test(
"10000000000000000000000000000000000000000",
10,
Nearest,
"92.750",
"0x5c.c#10",
Less,
);
test(
"10000000000000000000000000000000000000000",
100,
Floor,
"92.796550900321772670136890308810",
"0x5c.cbeac2827b3b07fe40298ec8#100",
Less,
);
test(
"10000000000000000000000000000000000000000",
100,
Ceiling,
"92.796550900321772670136890308911",
"0x5c.cbeac2827b3b07fe40298ed0#100",
Greater,
);
test(
"10000000000000000000000000000000000000000",
100,
Nearest,
"92.796550900321772670136890308810",
"0x5c.cbeac2827b3b07fe40298ec8#100",
Less,
);
test(
"1/10000000000000000000000000000000000000000",
1,
Floor,
"9.2e-41",
"0x8.0E-34#1",
Less,
);
test(
"1/10000000000000000000000000000000000000000",
1,
Ceiling,
"1.8e-40",
"0x1.0E-33#1",
Greater,
);
test(
"1/10000000000000000000000000000000000000000",
1,
Nearest,
"9.2e-41",
"0x8.0E-34#1",
Less,
);
test(
"1/10000000000000000000000000000000000000000",
10,
Floor,
"9.9907e-41",
"0x8.b4E-34#10",
Less,
);
test(
"1/10000000000000000000000000000000000000000",
10,
Ceiling,
"1.0009e-40",
"0x8.b8E-34#10",
Greater,
);
test(
"1/10000000000000000000000000000000000000000",
10,
Nearest,
"1.0009e-40",
"0x8.b8E-34#10",
Greater,
);
test(
"1/10000000000000000000000000000000000000000",
100,
Floor,
"9.9999999999999999999999999999898e-41",
"0x8.b61313bbabce2c62323ac4b3E-34#100",
Less,
);
test(
"1/10000000000000000000000000000000000000000",
100,
Ceiling,
"1.0000000000000000000000000000004e-40",
"0x8.b61313bbabce2c62323ac4b4E-34#100",
Greater,
);
test(
"1/10000000000000000000000000000000000000000",
100,
Nearest,
"1.0000000000000000000000000000004e-40",
"0x8.b61313bbabce2c62323ac4b4E-34#100",
Greater,
);
test(
"-1/10000000000000000000000000000000000000000",
1,
Floor,
"-1.8e-40",
"-0x1.0E-33#1",
Less,
);
test(
"-1/10000000000000000000000000000000000000000",
1,
Ceiling,
"-9.2e-41",
"-0x8.0E-34#1",
Greater,
);
test(
"-1/10000000000000000000000000000000000000000",
1,
Nearest,
"-9.2e-41",
"-0x8.0E-34#1",
Greater,
);
test(
"-1/10000000000000000000000000000000000000000",
10,
Floor,
"-1.0009e-40",
"-0x8.b8E-34#10",
Less,
);
test(
"-1/10000000000000000000000000000000000000000",
10,
Ceiling,
"-9.9907e-41",
"-0x8.b4E-34#10",
Greater,
);
test(
"-1/10000000000000000000000000000000000000000",
10,
Nearest,
"-1.0009e-40",
"-0x8.b8E-34#10",
Less,
);
test(
"-1/10000000000000000000000000000000000000000",
100,
Floor,
"-1.0000000000000000000000000000004e-40",
"-0x8.b61313bbabce2c62323ac4b4E-34#100",
Less,
);
test(
"-1/10000000000000000000000000000000000000000",
100,
Ceiling,
"-9.9999999999999999999999999999898e-41",
"-0x8.b61313bbabce2c62323ac4b3E-34#100",
Greater,
);
test(
"-1/10000000000000000000000000000000000000000",
100,
Nearest,
"-1.0000000000000000000000000000004e-40",
"-0x8.b61313bbabce2c62323ac4b4E-34#100",
Less,
);
test(
"-1/2048",
24,
Nearest,
"-0.000488281221",
"-0x0.001fffffe#24",
Greater,
);
test(
"-62914563/68719476736",
32,
Nearest,
"-0.00091552725962",
"-0x0.003bffffa38#32",
Less,
);
test(
"17592185552895/72198331524186112",
42,
Nearest,
"0.00024366470813691",
"0x0.000ff803f3e00c#42",
Less,
);
test(
"21/787061080478274202283",
219,
Nearest,
"2.668153783851046068064085870059240647975574549532107864539271612541e-20",
"0x7.dffffffffffffffff03fffffffffffffaeba40000000000001e821E-17#219",
Greater,
);
}
#[test]
fn test_asinh_rational_extreme() {
let x = Rational::power_of_2(-(1i64 << 30) - 10);
for (rm, out, o_out) in [
(Floor, Float::ZERO, Less),
(Down, Float::ZERO, Less),
(Nearest, Float::ZERO, Less),
(Ceiling, Float::min_positive_value_prec(10), Greater),
(Up, Float::min_positive_value_prec(10), Greater),
] {
let (c, o) = Float::asinh_rational_prec_round_ref(&x, 10, rm);
assert_eq!(ComparableFloat(c.clone()), ComparableFloat(out));
assert_eq!(o, o_out);
let (c_neg, o_neg) = Float::asinh_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 two_x = Rational::power_of_2((1i64 << 30) + 1);
for rm in [Floor, Ceiling, Down, Up, Nearest] {
let (c, o) = Float::asinh_rational_prec_round_ref(&x, 100, rm);
let (l, o_l) = Float::ln_rational_prec_round_ref(&two_x, 100, rm);
assert_eq!(ComparableFloat(c.clone()), ComparableFloat(l));
assert_eq!(o, o_l);
let (c_neg, o_neg) = Float::asinh_rational_prec_round(-&x, 100, -rm);
assert_eq!(ComparableFloat(c_neg), ComparableFloat(-c));
assert_eq!(o_neg, o.reverse());
}
}
#[test]
#[should_panic]
fn asinh_rational_prec_fail() {
Float::asinh_rational_prec(Rational::ONE, 0);
}
#[test]
#[should_panic]
fn asinh_rational_prec_ref_fail() {
Float::asinh_rational_prec_ref(&Rational::ONE, 0);
}
#[test]
#[should_panic]
fn asinh_rational_prec_round_fail_1() {
Float::asinh_rational_prec_round(Rational::ONE, 0, Floor);
}
#[test]
#[should_panic]
fn asinh_rational_prec_round_fail_2() {
Float::asinh_rational_prec_round(Rational::ONE, 10, Exact);
}
#[test]
#[should_panic]
fn asinh_rational_prec_round_ref_fail() {
Float::asinh_rational_prec_round_ref(&Rational::ONE, 10, Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn asinh_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {
let (c, o) = Float::asinh_rational_prec_round(x.clone(), prec, rm);
assert!(c.is_valid());
assert_rounding_ordering_consistent(&c, rm, o);
let (c_alt, o_alt) = Float::asinh_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 {
let (c_neg, o_neg) = Float::asinh_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_asinh_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::asinh_rational_prec_round_ref(&x, prec, rm);
assert_eq!(ComparableFloatRef(&s), ComparableFloatRef(&c));
assert_eq!(oo, Equal);
}
} else {
assert_panic!(Float::asinh_rational_prec_round_ref(&x, prec, Exact));
}
}
#[test]
fn asinh_rational_prec_round_properties() {
rational_unsigned_rounding_mode_triple_gen_var_10().test_properties(|(x, prec, rm)| {
asinh_rational_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (c, o) = Float::asinh_rational_prec_round(Rational::ZERO, prec, rm);
assert_eq!(ComparableFloat(c), ComparableFloat(Float::ZERO));
assert_eq!(o, Equal);
});
}
#[allow(clippy::needless_pass_by_value)]
fn asinh_rational_prec_properties_helper(x: Rational, prec: u64) {
let (c, o) = Float::asinh_rational_prec(x.clone(), prec);
assert!(c.is_valid());
let (c_alt, o_alt) = Float::asinh_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::asinh_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_asinh_rational_prec(&x, prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_c)),
ComparableFloatRef(&c)
);
assert_eq!(rug_o, o);
if let Ok(f) = Float::try_from(&x) {
let (c_alt, o_alt) = f.asinh_prec(prec);
assert_eq!(ComparableFloatRef(&c_alt), ComparableFloatRef(&c));
assert_eq!(o_alt, o);
}
}
#[test]
fn asinh_rational_prec_properties() {
rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {
asinh_rational_prec_properties_helper(x, prec);
});
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_asinh_rational() {
fn test<T: PrimitiveFloat>(x: &Rational, out: T)
where
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,
{
assert_eq!(
NiceFloat(primitive_float_asinh_rational::<T>(x)),
NiceFloat(out)
);
}
let test_s = |s: &str| Rational::from_str(s).unwrap();
test::<f32>(&test_s("0"), 0.0);
test::<f32>(&test_s("1"), 0.8813736);
test::<f32>(&test_s("-1"), -0.8813736);
test::<f32>(&test_s("1/3"), 0.32745016);
test::<f32>(&test_s("-1/3"), -0.32745016);
test::<f32>(&test_s("22/7"), 1.8626792);
test::<f32>(&test_s("89"), 5.181815);
test::<f32>(&test_s("90"), 5.192988);
test::<f32>(&test_s("-90"), -5.192988);
test::<f32>(&test_s("710"), 7.258413);
test::<f32>(&test_s("7101/10"), 7.2585535);
test::<f32>(&test_s("711"), 7.25982);
test::<f32>(&test_s("-711"), -7.25982);
test::<f32>(&test_s("10000"), 9.903487);
test::<f32>(&test_s("1/100000000000000000000"), 1.0e-20);
test::<f32>(&test_s("-1/100000000000000000000"), -1.0e-20);
test::<f32>(
&test_s("1/10000000000000000000000000000000000000000"),
1.0e-40,
);
test::<f32>(
&test_s("-1/10000000000000000000000000000000000000000"),
-1.0e-40,
);
test::<f32>(
&test_s("1/100000000000000000000000000000000000000000000000000"),
0.0,
);
test::<f32>(
&test_s("-1/100000000000000000000000000000000000000000000000000"),
-0.0,
);
test::<f64>(&test_s("0"), 0.0);
test::<f64>(&test_s("1"), 0.881373587019543);
test::<f64>(&test_s("-1"), -0.881373587019543);
test::<f64>(&test_s("1/3"), 0.32745015023725843);
test::<f64>(&test_s("-1/3"), -0.32745015023725843);
test::<f64>(&test_s("22/7"), 1.86267921113461);
test::<f64>(&test_s("89"), 5.181815110469487);
test::<f64>(&test_s("90"), 5.192987713658941);
test::<f64>(&test_s("-90"), -5.192987713658941);
test::<f64>(&test_s("710"), 7.258412646528284);
test::<f64>(&test_s("7101/10"), 7.258553481541301);
test::<f64>(&test_s("711"), 7.259820104902117);
test::<f64>(&test_s("-711"), -7.259820104902117);
test::<f64>(&test_s("10000"), 9.903487555036127);
test::<f64>(&test_s("1/100000000000000000000"), 1.0e-20);
test::<f64>(&test_s("-1/100000000000000000000"), -1.0e-20);
test::<f64>(
&test_s("1/10000000000000000000000000000000000000000"),
1.0e-40,
);
test::<f64>(
&test_s("-1/10000000000000000000000000000000000000000"),
-1.0e-40,
);
test::<f64>(
&test_s("1/100000000000000000000000000000000000000000000000000"),
1.0e-50,
);
test::<f64>(
&test_s("-1/100000000000000000000000000000000000000000000000000"),
-1.0e-50,
);
let x = Rational::power_of_2(-1070i64);
test::<f32>(&x, 0.0);
test::<f64>(&x, 8.0e-323);
test::<f32>(&-&x, -0.0);
test::<f64>(&-x, -8.0e-323);
let x = Rational::from_unsigneds(1u32, 3) >> 1100u32;
test::<f32>(&x, 0.0);
test::<f64>(&x, 0.0);
test::<f32>(&-&x, -0.0);
test::<f64>(&-x, -0.0);
let x = Rational::from_unsigneds(1u32, 3) >> 140u32;
test::<f32>(&x, 2.4e-43);
test::<f64>(&x, 2.3915493791143543e-43);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_asinh_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_asinh_rational::<T>(&x);
assert!(!c.is_nan());
if x != 0u32 {
assert_eq!(
NiceFloat(primitive_float_asinh_rational::<T>(&-&x)),
NiceFloat(-c)
);
}
let rug_c: T = round_once_to_primitive(|p| {
<Float as From<&rug::Float>>::from(&rug_asinh_rational_prec(&x, p).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_asinh_rational::<T>(&Rational::exact_from(
x
))),
NiceFloat(primitive_float_asinh(x))
);
}
});
}
#[test]
fn primitive_float_asinh_rational_properties() {
apply_fn_to_primitive_floats!(primitive_float_asinh_rational_properties_helper);
}