use core::cmp::Ordering::{self, *};
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::{Exp, ExpAssign, 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::common::GenConfig;
use malachite_base::test_util::generators::{
primitive_float_gen, unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_3,
};
use malachite_float::float::arithmetic::exp::{primitive_float_exp, primitive_float_exp_rational};
use malachite_float::test_util::common::{
parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,
};
use malachite_float::test_util::float::arithmetic::exp::{
rug_exp, rug_exp_prec, rug_exp_prec_round, rug_exp_rational_prec, rug_exp_rational_prec_round,
rug_exp_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;
#[test]
fn test_exp_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 (e, o) = x.clone().exp_prec_round(prec, rm);
assert!(e.is_valid());
assert_eq!(e.to_string(), out);
assert_eq!(to_hex_string(&e), out_hex);
assert_eq!(o, o_out);
let (e_alt, o_alt) = x.exp_prec_round_ref(prec, rm);
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e), ComparableFloatRef(&e_alt));
assert_eq!(o_alt, o_out);
let mut e_alt = x.clone();
let o_alt = e_alt.exp_prec_round_assign(prec, rm);
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e), ComparableFloatRef(&e_alt));
assert_eq!(o_alt, o_out);
if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_e, rug_o) = rug_exp_prec_round(&rug::Float::exact_from(&x), prec, rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_e)),
ComparableFloatRef(&e)
);
assert_eq!(rug_o, o);
}
};
test("NaN", "NaN", 1, Floor, "NaN", "NaN", Equal);
test(
"Infinity", "Infinity", 1, Ceiling, "Infinity", "Infinity", Equal,
);
test("-Infinity", "-Infinity", 1, Nearest, "0.0", "0x0.0", Equal);
test("0.0", "0x0.0", 1, Floor, "1.0", "0x1.0#1", Equal);
test("-0.0", "-0x0.0", 1, Ceiling, "1.0", "0x1.0#1", Equal);
test(
"1.0",
"0x1.0#1",
53,
Nearest,
"2.7182818284590451",
"0x2.b7e151628aed2#53",
Less,
);
test(
"1.0",
"0x1.0#1",
53,
Floor,
"2.7182818284590451",
"0x2.b7e151628aed2#53",
Less,
);
test(
"1.0",
"0x1.0#1",
53,
Ceiling,
"2.7182818284590455",
"0x2.b7e151628aed4#53",
Greater,
);
test(
"2.0",
"0x2.0#2",
10,
Nearest,
"7.3906",
"0x7.64#10",
Greater,
);
test(
"-1.0",
"-0x1.0#1",
20,
Nearest,
"0.36787939",
"0x0.5e2d58#20",
Less,
);
test(
"0.50",
"0x0.8#1",
30,
Nearest,
"1.6487212703",
"0x1.a61298e0#30",
Less,
);
test(
"1.0",
"0x1.0#1",
100,
Nearest,
"2.7182818284590452353602874713512",
"0x2.b7e151628aed2a6abf7158808#100",
Less,
);
test(
"1.1e9",
"0x4.0E+7#1",
20,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test(
"1.1e9",
"0x4.0E+7#1",
20,
Floor,
"2.0985767e323228496",
"0x7.ffff8E+268435455#20",
Less,
);
test(
"1.1e9",
"0x4.0E+7#1",
20,
Up,
"Infinity",
"Infinity",
Greater,
);
test("-1.1e9", "-0x4.0E+7#1", 20, Nearest, "0.0", "0x0.0", Less);
test(
"-1.1e9",
"-0x4.0E+7#1",
20,
Up,
"2.3825649e-323228497",
"0x1.00000E-268435456#20",
Greater,
);
test("-1.1e9", "-0x4.0E+7#1", 20, Floor, "0.0", "0x0.0", Less);
test(
"7.9e-31",
"0x1.0E-25#1",
50,
Nearest,
"1.0000000000000000",
"0x1.0000000000000#50",
Less,
);
test(
"7.9e-31",
"0x1.0E-25#1",
50,
Up,
"1.0000000000000018",
"0x1.0000000000008#50",
Greater,
);
test(
"7.9e-31",
"0x1.0E-25#1",
50,
Floor,
"1.0000000000000000",
"0x1.0000000000000#50",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
50,
Nearest,
"1.0000000000000000",
"0x1.0000000000000#50",
Greater,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
50,
Floor,
"0.99999999999999911",
"0x0.ffffffffffffc#50",
Less,
);
test(
"-7.9e-31",
"-0x1.0E-25#1",
50,
Ceiling,
"1.0000000000000000",
"0x1.0000000000000#50",
Greater,
);
test("0.12", "0x0.2#1", 2, Down, "1.0", "0x1.0#2", Less);
test("0.25", "0x0.4#1", 1, Down, "1.0", "0x1.0#1", Less);
test("-1.0", "-0x1.0#1", 1, Down, "0.25", "0x0.4#1", Less);
test(
"-7.9e-31",
"-0x1.0E-25#1",
108,
Floor,
"0.9999999999999999999999999999992111",
"0x0.fffffffffffffffffffffffff00#108",
Less,
);
test(
"8.7e-19",
"0x1.0E-15#1",
128,
Nearest,
"1.000000000000000000867361737988403547582",
"0x1.00000000000000100000000000000080#128",
Less,
);
test(
"1.0039471e-40",
"0x8.bee08E-34#21",
141,
Ceiling,
"1.0000000000000000000000000000000000000001004",
"0x1.0000000000000000000000000000000008c#141",
Greater,
);
test(
"2.781",
"0x2.c8#7",
112,
Up,
"16.139182322446412960131458816413769",
"0x10.23a173e316b31a0e39d1deb7274#112",
Greater,
);
test(
"0.693147168",
"0x0.b17217c#26",
1,
Floor,
"1.0",
"0x1.0#1",
Less,
);
test(
"1.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333\
333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333\
333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333\
33333333333333333333333333333333333333333333333333333333333333338",
"0x1.5555555555555555555555555555555555555555555555555555555555555555555555555555555555555\
555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\
555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\
5555555556#1100",
25000,
Nearest,
"3.793667894683177735396304360505165314661714629412615875592525513751921430417245346031174\
008779637452968258902978182244980121060550395067222862278342600586042666216447101910980238\
517204902041167331365083583696015229342506930429419833165233131242804228109011585352358431\
810090522761028470216180584393248594717956062593337556585050548017864513705899377779843364\
240441136737028704527871322993229996540117842579491549602233480973524229451013637958486244\
991920839966759998180128808654702465530153806696529644286184779721878614958316403401990303\
499803243450137425213134544280705471019067396031788548279467043285406848236655679683307816\
892270448865339261469196369150936775335944598946859512831583327357841954593664302596809480\
426986917936710006734552715463590478872660048174501893807506879296334859805839533075385486\
373317833979531245881220885032717395491653852502036773705536424730457930774973391982029255\
868322902321921289730244634322360289230109078012130660125374940714357548750453691301162772\
840883295985117826661491757666710372555681961182499133679513515189573831031228259917175565\
329651098744302600250384970574404723177202571827387544482103756843335366919737956676089442\
284419248657642004737872690781054766393720079888019198450108770445699196486352557485635827\
102673343408185806352921890169325654911296309447788893032682202086713696635010434040147923\
083458912787194936363036165555563037283188704971402147470012527112374934092550651858771705\
011387108203577738814600340964902236222109322234043321283171752875017005246345253270578274\
589315482228227198020109830648888207479910156661538697011197370901830084854312244990771349\
659995784664581803293024169424656615016212510408530366132247282328746333653090256764162564\
180521542938303371047262252944850763639559322420187592903047506248577685299716818536591011\
287366194088221831929931739219829824467083429918867218645515729156467610200719596337781153\
167646947718991285698254318518769965297827235095600960150664861528196441498100075892193058\
565027874614478529244999493991496457239690538834960670632695163748104680146644026223257206\
999485759367963128534611739758512764918089322567475799232283231939888153365249788864416911\
712483659860140023513831627200728467877529687925884881690244324206445658882444053060246991\
383600740466974469116298989562489789246250556750038295150203140719613584290916390659335746\
767072173438403430812463792365550976494270060259017803807749647343652427607348580396104675\
600228933616694616274255998294445391776305838971169896527005624099463259778853209678282065\
919842254896646405849339910797858732341277981594095179264273614326222623992049788589884808\
836741025333322765674832812370452290887078534025335091240984292221718472212279896342616647\
328433445910849595629701292689265555192815679745447559240419925235212494103778656643687565\
488783501275828737329682982256958498911329906635341315048731287766437969549485568564120311\
075174369985486879977325315520832981264014258212169851747442173890167584705663647015227324\
208890241636129492810986185778842459915057781780714912163290787480062517474785554033423516\
490681611472483853025733081342056735277987842248605805310631643464662210948093667908830762\
444982200446211106958930987887244360477582120384409256291186631576086347063057940230470970\
615104041859833995398587318440585165400330088075298369571550605559047109634760946813127664\
720971846602683717734007286487280794967320323408096871628510536512971162243646070468812611\
230547018756084037551751462244188941727917809649624935782525327138809961784245569651511034\
437163745014794885637058215001055070636784597576686159268574399300247292231384042577497149\
122195972267759572994541780472948777844962483976981174114136007351960251745030106048819528\
194497131791075021654689149739822957524299648075328292819635511338034602831141915832938243\
472128826449077581444577698694224815865794424861027833966413832140868749827809022100260719\
975551124464726347122950675437074370753907168453114402867639893130545391110205853692047004\
862125739423607070392723646655012462214517666138755763414384312899496711107384229987199366\
572348988894262789021683826644705636933254490937165918253300402349317462242363772036390496\
431103930141476551524494740583196094440323594901905605431971260563886230257262342067168307\
550130707810110175167656552392353738770544786823966581978818228337599754909201331912252183\
742231460384309195078830781328833265937490432987956432939877613160858744115362649663666470\
720086765369343698137733705938981334939813418216783449947704421451349554726109331413979735\
369015075378500761942863047071134509470116956463401174612347013560699619353489238124046088\
658305225305223616046884009983792397371171757324125775627534144978084143416090254469390444\
879463539356779014183900774512537684254848852215910814165591655297836161945232243443440784\
087677618073939129326426714912128657260177383007719894792437161240578764513079140373090313\
779516737390905365582197593161935068902193485120550300737264847516785660428638157360684803\
219695930907706876803105778563977368765230477429225541866310273494982180531993176345096192\
812696336436978160969175196704153262590884933050597929563961276895294845893550316749737435\
535629892558935938941950406920008865225137336204980570842665193971326850343721809780896694\
926496548394345845253604713410332909670822812201066516262469943003163441140381914805404314\
390184405533861550110447315970463811560149344512116663872379941905715774840247432146851109\
090830474465478189976017522459916738803094166893878288495455115879680516580668391933733924\
134086314146947843804730096091680393610197861034141906198207420401247876132841612459786420\
445907230301615640274137994604949826742232869172814738933589640182213169544084594560049835\
297872037539502206497648684807410844652734297537996269114760064914205638641244506840303543\
095344621011766969781431755048236577526428688276697502164527413143764716341632430807114770\
354853725551403797122177344048728105419840370581346448687094205359812393248434400368162690\
990892290939610345554452266801066697381219536376669946174261339379723070736135736629277287\
922272487467586545595819224960602675136747959386226060777687637638652762748861946172356822\
355074763915700291835043074410543861503892811247444873287047463796812709447664947376594486\
856803814119550044919861461652059863269516916565815526400265171964968564088767440670034380\
521572183579482513543893878007684815095929108665998276235588917301672111708549464717981327\
389570875426915159142624924157398293597397192289057013724511000104384060020252726858510927\
621830122792962640584335432703123662612199776414781808730122183696259175726656380608920021\
933735425614400212809912935423363085279814490880841637439254052068216115588113194072611676\
472282186915130050738415944503544911146546970015286271475442357778676985647093052095211552\
457312019684570167478287965937644803807508932655944745878369856069729218096030265332497040\
383678589538724542530669893057712383906809068990606015814873085783336938471945865466284500\
120816927359841362614148887602905444019646032449761554060976995291848440107926355519667041\
569780054750033035743808505797093436498803119880617741842485069846760791877179373546773660\
604275855912188881132915368498270876610414672731597817179087752559232001408716574823968692\
479487401277242052279916636203810724431445008091964509826650341473347703481031221691642624\
764501565813547132119544877012732502259399462367189646572405808552312544971777283593612716\
784601627597939088686280621473810853088051383380912202788833775968198265394553383824684504\
01169265297338805569564284141536981083557822677308667351706",
"0x3.cb2dd1b38ca6d500779447ef42e1caf5dd5f6826e4190d0fd4e3e11f01aa2029312e3e8554a82688ffcdd\
6cc36f5a9d50c1d1903edccb582a5bad8f0f6fc5c90dcd560c961a6e2f487d3be890bbdc51095b8ea166842b7d\
93f23460f4b61326d5d654d23482f385eeda02eb7a7a560a86d3eab1316f9c27d137b0d1fc7d6c36bcf2e632d7\
1268b5f4d9873e4ed72a26d57530249411a5932d99b34ebf5afc3b27a6e6039ef5ad938351b8e370bece1fb9e2\
0c2bc37a96e9d37f9a84eea444084eb800f7f582e7fc5d05b0057ce7599b089eb03f1058538b0655953d300b3f\
126f7fde480ca1557a7df5c90366bf91e8d3b8f0390ea81cf49ea472f9c59ad56e6509063ba415399a05015a88\
ad5f7833cd7751b9a204cc260171b199b3177dbc50008c38ded02a037e3c8c7204658f0ed61e6fb3958e807ee8\
71e1133a7b95a8c257fff1651eb98fecadf3c8468b3e43311a8e1cb427d28bb85e61bf796ba68c10a4d82b00c0\
f3947fef71a32ded682c21ecb506083d8fb0872be2b02a7c08e5a33b6ebf7e91e027bfc589a6412ea8305f1188\
3578e01c97c2a6aace35bc6d53172809cc19b5f9176d75890ba8d43f048b2b8f404bd607eef8c183c89bd32076\
103d43c8493cea504d40770a7323a2e1c26c3305a1de0bd595337eca0361d98b113a6c2005b7de7a3ef4087558\
337fb1247e8a076b5895f815afd7fe3c86a311411c337840315a294bc897b4869acfab588076f887414d980b53\
bf497d95017e7d5761d40ee656d5435ab2772db214b47526a1761bf7143e5440ba4070116a257bb255a0b6fcbd\
b2b03be69efde38729139c6fd470fbf61f3feceb264221af1d678abc8bb20ffc10d1e82c68d5e4183a468fcbd2\
81d6af81347161d204ba4b7d373c6406024579d0602022786c46297b2bd0d0f0f06722dc2af3c7a084506ddece\
d1024227732374f78fbe7d48f6764fd3c20e806a5b0df2bb1ada1b53bc2c3ffcbfaf971219a8338a5537a72f38\
9701c1e9897ffa88e32415520344fea2a382d384d7a3f4ab45f015a38b2e2bd831f842bc8f6d71895cab2432ff\
b70baf838983a3dae4874ee21bffe448876d3e58e488b5cc84060e81a0a9e0177a2f7ac0d9065888628a395a41\
4914bca2a436eaf425bd6486f518f551edad667cf935cb596f9f2779d0ca98b06b21c63950f9d22a80bf226846\
a144cd3c17223f14f723531ac67af9505da48a53da3220a4766551010a201ed2f0533946ffb97183c9e15b8347\
1c48c8cca0cb8aab26f00bc22f971a31befd0b331c079d4f54c22731589bcb88103770493bf7c349c0f5a4cb9d\
99b9b980410c2e3b9a265dfd7dcc58ab1491402017037477c0ab11828ccf963aef6bc2276255894bb1eec73dea\
21ea29ba3daa993beab4a913e407863133106587b0bf38438139342d6d67e6d7892106d1819d53bed4f3adceb5\
e5437393226d4f43e44903af9373e072d7c0ce4cab9707cd1be1166865e41456f4e51366531695da3f657de138\
9e1df38dbaea56b83d4e52fbb18d4375644d21b6aeb78687424c23bdbb362b673839f24a05ea8c2319d42fae4d\
ac7e02431d95d1114ea5c9dfead960792717e5aaa82fed3d56494f08dd38d111c59c1af09b163c2933a1a1c8f9\
61c2a6804ac93c6133b92af3827fe82836c322c40d737ffd9557be9e30405e3c9018d12abf0b01e57794708d08\
77be4048e4a7cc8797959032136132b4940df86a7bf976bd915ee104e9f53e49e37656813722398290ec01491e\
1af3253fdf233dc50b1586e71553295853d655fa27d914f6df0814eda951dbab2fc95c579268b7c59d05952347\
a118fc89c96f9ff1f02391581b3537ea30c9b4e255413fc370752d34a9d371b7f0ad017f2fa6aa621d0de96e01\
bd50fcc8fe74776beabd3b2c59753ff72516eaa7f66d1cb2bf97e14eb6f981d6006b2e5f15c618910e5e197693\
3c49f999de6d921b291f52667c1a5db15e83d96318dffca880ffd194cbaa8c181601c4cc6e253cb65042c71176\
c86c8e439a7f01bc1efe677b73d766f0f968d6d8483d523d4e05098eca3fa86b4c38825f0f9b7f3afc8e2fdc31\
4fab53e03bc56e357bf524b2eada78118c494eafafe4fe29f7e28f2733b8d5a35141173c86dd1101b5ccb99a4c\
b4327972cff8594b4bc7732a93f327e1d15a61ed6b4b449dc1344e15c0cce0ddf7b139e1fb1d3ee1d3fa6bde4f\
8b95527759a39e4729a9598d4907deb69dd9b900ec1571da6c1614ca9a77fcf6a9d18f9225887f938d397802c9\
ba8a9569b7fd8c88abdac6474319e874b1ee714c0ee6c4f12b45d2d90e41f589073c658986605f5bd054c439a4\
41027b2273a5a69d37918103eb1eea9968f0d09da889606c2932122ac36cf6f0becd2a726c53c57ab575749439\
5efdf1e041ec10e6a1bcaed54bc7eb1415653e0647e4bf4746e57b6fb86386dc9c0cc1d967fbb32f155fc376d0\
86978c36ebc10d6b52c095c7242f40bba26e05ea70d4703e1ec0adc6785bbe750331fec3c248db2038c2d69b5a\
fec01c5ed3af7e184cc3e6ae2b5bfa3f6b453ba2bfa38548f23e2866fc22fd9c065405b7ea240b5524dcb25924\
ce3e5a078730a450d44279c006651857143c0e338a218f9030ed932bb76975777f06b0fd8ca4a7ba85e0c40655\
f8e71cb6501cb10effb3b5d5ed96c031633c53b38042a6bbd3020f186140367c7f7fd899a259a54efe2b9da1e6\
430d1ed50bb14d23dc852d78ac6e615e9e5137cfcd8b7c49944fb4deaf254d4a97fb17afe3f90af067a83fd714\
7f9f8fb1c202c9c34c672d6f56e7bf6209de46d3b8b40fcbd218f697634ffcca4b6fcd042b5ecfd92ef2d03cdf\
a25505e3a3bda97140524156f21472663ea9d2bf207cea27ab9b35fbb44c1bfee1ddbb28978b4d7f26f1d1d1cd\
4bd027a5f157160078e1786d6290a7eee924d527781e8e648e4e995da1302b7b9ec2daae8d6186b44806d10fb9\
d9d514f7e699e33fa86ddcedaae7c9441c8f3dc4ce3ff80a0a8fc676f2489467a8653253dd7356ca01e88c71ea\
f50be9682ed1020269674973ae3eb8a3606f2c5dcd46e1668e89a1a3e6f200712241edfc2d739638ec6ae427fe\
162598703b3db0dc074e7592e13bb403a336d507513c51ec6088bd69178bbef4a84bd29fd80dbb1fd6cc5dcbf5\
2a7a1870c27e5b60aea13d00495743ac3488f5f7b4fd5b0f95cc21e0c4399f6385f7e439196744d0e183506ab6\
1d97a24e6e308b37fb438f912301d4334518123f7e8ea3af66d943473e0bffa49ebfee89cfb9623c18fdb483da\
28540e1d024ce9efdfb1abc70003ca2d76d944b0e35dfdeeba73506cb769b685ebd46059f41910599e82483990\
dafe9dd7519dce236d858bdf2615b07c3b8ddd8c19d18769cb4bd8042fdfbca3c3ca851672e9631ddb3382d19c\
6ad33705a677612b5f52076d0b9276c891d759ac5553b166f224929c4f26b5f9887b8ee88ac2e57b2e4baf3b4f\
fd621f113b0be646182017e6a22b7aefe4e4d21bb6326f96010903fde5b2248707995245d9de7d277537b98359\
b4a83185bd9e701762a7b4f8bbf0236f203ebfc9a15087ce90f0aaba613f6e2235e6684677d8d8d1534b036ae7\
49fd1aa02d6a32cb59ba608ac54424097e42176367f8519ed8ada83c34a70f8c30aa2ec1c48c0cd62dc145edcd\
56573f5c262a4d7d9430f638568be6648d150d2cbbd360f9b1d47b3c48ea8e548f073e81043069756ee2655a65\
0c75bd97ccdfe226bdee6cb0d887155ba63038e2bfb15f901db3a96d8724cd21acab981ca4e7dd411ce77c46d7\
8dae048bf91366341c05fbab900441b3924a7dd549333fef4319144389a3ce39d747c4731e056473ba71c5a397\
8b8519c1568894377001208ed1ae7e8e93e3200422f3eb0cfa4bef052315b05ed8139fcadb7f700e29e29239b3\
dd59e43c34a903751906a637d23c72cc4de884207c5f12dd938556c6e26a41c06e7660cb78d41bbce9ff5a5311\
ac8916ba36779278c4bf888281afb8582f7c82de8b8c8a57a5f27869303ae749eeb5eec19580837c07d14194ac\
de04ce2afc2cf7d152d518b66e4163efe0ae8645ac1d57d7ffe5e52269a3d28bfb3658643cb06963989f323ece\
35807e4e3fa5089a9703d5d7bb7df5299ef45c70e464604904ccae88fecec49b2224767229aed33e127ca406e8\
c65376803e8f9c28d788b1f206027eb68e41b7488db38cf68b62fd8e1e6912ec229ee0190a88bf61ace013cbe7\
78616075516c960b2d226795afb2819c03e5bc8c66f517115fdb1efef4f375809bd065510a719616e0b0f341b5\
5e21a9e5e8a34de49901b31540a3d0fea88d4da092eaf7254375014af501c0ad2af6aee876933202deb9cbc257\
d874350e5eab4aaeaae759e1f84d16e76105308d26374#25000",
Greater,
);
test(
"0.500000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000087",
"0x0.8000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000001#2000",
25000,
Nearest,
"1.648721270700128146848650787814163571653776100710148011575079311640661021194215608632776\
520056366643002866637756307797004671166975219609159840971452490059796929422659098403914719\
948464659489244896868905336418465720841066656859800088924981211712287375214972195511971609\
034091115619799869839960642655091754574626304483075194758258782625439931955712690076545322\
881476100957739788486181443265208203424170104718338591510630125661475533808252026061400972\
891959084050148915029440695633113776763800958480893295122472263556542654171757524108358697\
276592606615399767667602791615334471108288209526962579040493568560297944408515972363507601\
003620897524567885381377217325999880080460246785789850175802943867610048631617415400935356\
605461602766754525001784798933564119532374370742194486317340578923009982683295269460971316\
828114841178341463155591940258301048189739952183091315826278282934120356823527366342264468\
651582077977866405108339295273323438665614832630838242899953662055897712669571977802494373\
063436701123695037161871216373260476333206445238119847968890079810554767402386891894130132\
087809165622841596937133266577255540544747429602644029199574082031275432228334819592563749\
705597676321538191213153491953432014981762084236859558468850404479299595861464774454884835\
256273249964978591088043235575381274454937876348995644928555248399316976570116584735770853\
689342807649560674008083819681690544494809718023569469950459355917718143323561599959127141\
702740055145868457409698528557293649924786256054305588049613304267868707211119998530962291\
519867240964868465287480795840429443982082864274330604880661553205462672190101838219732679\
900546196824996284485575746666962530622235243883420622730543545285364206365643772881414926\
943379124347569453375053832220041446028918429445481790507483986158041731510819774385919717\
865403902892070804493398112031056231034016971388886700389948100374024145725559584564135762\
504738589774517695183834852435870579619910385664326551111491798897645679873231857582205671\
513108125414284298785363722511009646134622080464552950481569768118076570127151380076841653\
009180408770755110564765671971628509662637430909931484452912622128833687786967139932829441\
394572301905844071237087619401780009667372880222725411408068352940434100262737023887920972\
447373678963386721990170336373540395752831454702383200146063197068289004045492061603716808\
204259462313701730227643622426186897379348487047330266203339708227312985759861932413250050\
251638972340080352896807071753538846633556187216511818015621687968833915850594796604708428\
560333519995921626544494034487663625305436434785095956067612767909870663590660749779917283\
400912658577669588161830197095956943185177869866332984423176523106603772355896695874014828\
765726812108796382266769343373911463043999949345265584260084007363480953173733724701182481\
417022021264002447461008182637667033175885421743637550974952727265628660391681204066519403\
684333063194252513821460524285984236343905163843250372160348143692646272150400206684618836\
127885943947964312312689236500596113828435432338970310088016474727893130609021384241500587\
486822254969103321131356597467223543560624413084434215145176726337529317427348032234306529\
556545320205047432123745084952487495924119293611042828586611405248180809803211636100283024\
575772393796076849080378185454082669578054340458519113867059812791817443869661571238503568\
775752261617602003887924700860073155127127232690651150977557832922731350844407742640637992\
460781174855249165206157129247767403832632274477891118036283688776367054339382543258885716\
789219136934349895285654690925622635405706169037246968442713910359376626503187201288802973\
075412609774318084856976980770500709424214842492293511550213538058290544259693028808795709\
869560343789634130766487840222766272910297716564709403787017652330780159926399676514793323\
613092091547484446451554493242942410343832534776462624791210893511747965230009272720434809\
899187467222278284200411738191597968801481692019074817955460014107098172288134307849687323\
967394211027013317575204871080443351728326505720327499998477602551721688157776980979589011\
591929269668574772783628811512552951956354606165237521011725601192537891116336059162235065\
872773612423865567183380113584606485955799149689189006209172562241261444482903748107181965\
561630711951223584231362565422242028353431725551937016828594029792061122282756953245929374\
207135816529292529090569764552355349298630617321361594552695486339880724851107539668104729\
809890423335081193042869975134431143816431591481728100457838594059188997344720362529936825\
906471263887345609299397926845889733738392252878512662687016987360150794537711277139950083\
467349188309115064297004053267184938380132537021309785193351952724361243343468553168065518\
738610012051566755386882951758972881717988476492203412420436403690877814768791344524089850\
466846460961698018814250823477177286620218233958838601373851361333568906715289641586974985\
603471441193824109648200295203666744303560902724441944488726531015237392165210976726890667\
057132834770581696525564214200104302095571491406959238028308869308464802305844018936643649\
545934937744077456117327721573318298461496225976938555898245009547673073661384373654865099\
120605121392850695130737174340957074789783122078373895232924155417982360550247154657130301\
259786633077462930987414729770232013022160284808875048151316113690461197418844924562185435\
153049710424942770795980204822607402349754707886756306721725479166495263270098378209473858\
107690397958494808253869629316239387589463208933359406531159950050894212992602556689208671\
205541132675975795719913550263512291834757081200374794680484931656943528441097395817157142\
484222767602723641376243363672167264366748069007977639082743855579586098382956347377853064\
943900978523322234129305217792615104747992303907179721122691960733604741871136600516451033\
368236456291897642748865364234023277088671527666189384902782115626018234838300914119569720\
409975024673747580267996465140319814224130727270912687460509156946579531364359442492478441\
027313162623352980843372242714622581526213778182554864371820371314552905438303468857177209\
619321121897377678022923792756455256261030683200147178121973282525970973623709338466031397\
435856637241045442554507584087282458731830306514557490129816567500246264797618599273069327\
302157246494568549811169649259952952694634750325325516863663925607478727840174490841015421\
874038164695000216926268823098274511637639484073442171344292224372954025683462073014506237\
939970778439023107603465035024228646403660873571733030165850445372751405559632628222453392\
292365971423145773115644076777226200527528488246394633477671571248807958829640073295423025\
937195438855843527364787777893727642781086776004445477556931363196750856121719581590851011\
770307860406412923742312527497740179362229546286949436997613580010973534983588538963626391\
095059408225196191844750467471923156598830604201837015266121811235155469445409023746429440\
939611671054862213139566101910214004233045743078391798514682326339160926295409991471637364\
349103391741948017686505856808036065661237258864227104943333466437097941387712784363949395\
054132564808399651089843333345627544202267280893565294470420188077919140970016913764311530\
281315923412781225344861367217860786217645746359877712461532537603177632322248869894240149\
022667062484419642578412246906027457734135418481321184142048431397927827349218612079850252\
919284567471465989480815631754991970537253471090730542888676358651141962956133350310663976\
350075012774115767916145919422295564584027612009181722093765103558443624484221171899392800\
44555421693191325955489355621099061397305443082664119818288",
"0x1.a61298e1e069bc972dfefab6df33f9b1f651f16c130b4759c44bfc906367f2cc2ef57279a9122e213e6ed\
bf79715991749ed598cf661f23b5c3375002b625e93f40073aefde3db387cf93343301d26f00db4f79933f2185\
bd289d11d44fc7f4da9564d60110affd989d4a081e0e7d2e67093702b425fbe4f487f6b7d51ece74390f3ee229\
38221f137f7969f68a133f8fcc575c6ca0de9f9276e5c5d7c3e72a3404110fef58d0e8678d57b654f193d0c824\
aa7d0542b23688685b874cc13bdfc80c365a184ea8a1682aa1d570ea0b21674160c5f817dab5ccad1d0535a8a2\
063357443b76b98327a75a3dce57e9e87340096065089cbfb227deaf7f34d1a70f60848bde5df3f0b2ece50f24\
a7b695496b4236af7e5a9300b314a04de4602d60f0d25256911d11db16cd01cfdcde79aa1a5b9de33305e5ed97\
2b058a892f7e8bf2f84b0f1fe1c601171e7ed8c6dcd1d1a3992fa5de9e51a1166cf004b930b43af27f673bcd2a\
36225ca5df2c256fb2a0374135cd4329c934c53339183839940aecfa48641a9ec37845ffa8234d81c1f8b45ae4\
9a196a69c56be6601bf490ec9008c5dff0319ff705eef69af1153100e7d315b258743bc02d31ad9b611b5e3af4\
8bc4715ded42b58ceea454cb88b1c387a2d28e15c273b37b7fce919e76acd3021744efe194c6dbec9f404372f7\
b854dfa1aac5ff4d0b54d8eb0d22708ff2a9f9fdf889256d2a9d63415bace481898ca8e80e5cbb57067b2136f0\
d77b5cc2fc5cca3a0c60b830b646f91e2122c3c1523c58ed8fbeedaee677899f10248b60f0b5ebbae6bf5319f8\
30e52cd4793f0daebbcf3c1ff3bce1ba257c0d2f6fd3adecacde981b56f4a1ddb123fadfc6c58613d4f44988da\
f0fecb5fc00f52d7f350b1a3f5091d84abcf7c11de7cc0effe7f6b8930412a3140c4a97fa94676e52346247cf5\
b3495747a1b8872fb20f996e41cee356d08e80703aba2d7be6242ae36394e661c315d6b6182549ff8e2d94efe7\
bd8121f0f7204744134075a44f7c8dc3568aa344f4878e0e6c450284067b55344d5572039055e578405d703208\
9428141cfa3ba929d0aa5ac2370d16ea5700539a3e053cec2a6d69ab68b621038645e0cd4a43f2c57efb107855\
45a5d13778a0d8fb7ffe6004500a2bdab68f60dd6642631bf9699c0a7aed6da74289b83e65bcf5f687bec98ec3\
df137f37390cafc3cda0fa5cb1492004c04068a2496bfe556cd840d462df6c13eddd71355f6f51696ca0f1a1b5\
55c10056feccaa918a23529f54d1f55112d47765e362c892f320b474c568f549fd08416da3f54b34191dc63d66\
3cf632bfc5bb549b6eccc4edae68f1ad2b1bf912b85fa4b25065a11b57f62996eb208f9c3a043d05231796bf3e\
b76ef1c0d082e19a9d47fd686af20a83250910492cde1bea23dde4d8edfce226ce855a1d929fc13f5e1156e485\
d11f51a5add8da4ee4cf7a90c331a8326dcb922db4dd3b3fcac074b3eaeacd94a1b4cac9e61ed48038107fb5fc\
21fb2f4e19679561b778a7c2aecb6fb2be7ca2b5b54eb0c2d45d61fc594221d0ffda44bab1b87d43ae35dda409\
ea1768ce4fecca37dab497ea574b582f8d6dbf8ddf997c1c6ed03e915ac3a9e5016243846e0efa5e6ab12d4db8\
d4f9d5bf9d814d394785f5a86a06103f5a3400606df1ea991a68cfb094f0fad97c6ce9ce8220f74b11a3c3ba61\
dd4f154e3c5be251ef1c5cc1e27133f336bcaf95232450ef00129c5ad8228fa31774072edb8264ab5b864a83bb\
3dc471f20f0c4517020799ba3a087db20fc93a399002048161017a53145eefe7ed4956a60bd594e32df7945060\
2e4cc92922f5c598022bafb1e941fb280b03cf6410fb93457e1348cb33885f8e299303d25c03813457369bce95\
03ab7bcda61bd39aa52dd597b05b676e85008e9b7bc4c25d6a418eeafd3aabe668eb69e412158baf941ccae470\
deba440f4f2a844de9d95c8dd5b8d28805dd2e7319b5ca3769d76f1afa68d90e2f7b13557fb9c89441210e77fa\
15908368ab13193e42d680fb817a57f0c047a45333ba036bdf86e5ada1d9acf783c9bbbef498860d074e1821a9\
e355a64a48e041d00a8a449ab31d8a7c05b49f6cc9b173132e130bea9f87981941a3d5ae5b946796d0bba83daf\
0f71ea2770a0957555e43b675413b5b79e069a545dcb23d35c7e4013be7fd62d4b27cdab092b196fc6d1302550\
289c4171fb6e8d488642fcd1c4ca9e6d8b79f7477760d85c136d2e8c977caf54fe4e9a87f7467c7058ffd616e9\
0d4b14cf80bdfe422ef2cba98e0ab5417e20ae2cdf2599d54ff85948e78470593dbf8b9370e632736a3d312fd2\
aaaa9fc6a2f0e776a860b2cacf2986e83c0e4bab65bc7d68066cc5f87aa0f3f1f0ab91e88e45b0d62f9d0c2d00\
66fc821837f0d1803cf7fd10f8ea1f380c0f660702869de62bf52aaaf2c7338f10fbb0b06713cab5d42b1cb64a\
95fb295afcd58e6af98dc873d7211b716b3eba0252e1d13b623d8206f5e76ec0323b96e1688a503a1b59296c09\
76b24cb3983107da2e084e47ef6d6f780bbc41f802f73bb7742a076fd765ad93bb4d72a9afb7668a22e1f5834d\
2e047d3f1b5a3ff8fbc0c49d7a2fc1c6e465d1a588866e13c36d440f00733f9e3e692543be6fe5063600d5e5e3\
4ca8a2cc6ab1e24bf7a694ff313e421f70531b8983d9dc513b5b604ce65282d5dba138cbc64ea2ef7eb963f407\
0ec85b5f19407383d4300523b6af78afc1010faaba9adcdee71e10d616e52921b836e02f18ef9bcf9e79d0cdcc\
fd1b7155ed865d418abbc155b2444dac335ccafdf785717b9ff304aeb96fa7c11dac2e00b5709bd430598569fc\
8bb2bc7fce20b58e0e79d6316e9b0cc67425998637bf534b861439594f55971c3e87cf16a5141c0a850d99b7eb\
a76c647cbcc8481220795f5f9c76da0dcac5f907b803507555e1632e4cd0e44844897a2c7fe22b298ce3396001\
94b1a532d4a4b72a28faaea29a59fac586c051c9ddfa836b989989471102eae536d615f91c07e4fe625a2d7b49\
296b17eef1c9fbacfa3f33c94e08eb648286b606e0a69d889a7c30e3a113a0b136395bd82430e311d67f2856dd\
ee51acb4b1be92fc346a24900de3c788d8b77f371eb88c477a51677caf20a22df6e1aee5467c6a1bdd6584fcd6\
ac498fe5e757f3e820f0225949f028e1435f2272a985ea2b669f70d6d7066634794268fc907bcc5e203a1f3f19\
2bbc32f0dd9923670193126efebd9d429c244abe3b0ea51a25c8a982f2e0fcdd06624ccec39bf9219e1c423ac5\
8b23f59215c37fde9f8204f9cde6cb76999be86c75dd387bf88162f38f8143d6f6a7cf94b74662ae83bd6d0a62\
58a7b5fefd30c184a8c50b5bc55335d4d8400de8348f5362d0d6f77e37a9f2f8f8beae771c9052bc20ee6aa0a3\
4f82c9c03525a94672a3f0e8e66fd384faebfc048a951437ef195a41d69ae2d3a0babb07f07fc0f452408a151c\
85e6f3e6e1a7c430caba6a32519adc5070d52632a9be78487b52aaaadcb95b60261af56eee2c9f90f446a8ffac\
a2cf4247452b37bbd3e23813b0d5aa01fb271ab37860db266b1f3ab32e3ce95b68f595b6071ab53527939a1958\
b0a9f01fbe2e179195c037eece8b16ef36895fb4ffddaa0a9359abcff35dabd8554ac81ae7c9af3af408358808\
31414227664db09d6d33499a9e2951d026444be1bbc5ab661747f954ac9228512744d166723c88f97d5a901544\
dfc92694290f81127939112bcd57d379f82bac5ec3552768e830dedb2ee552d3be19ac2d1d58eb98e7847a5c71\
2ef0e8d970ee24ec587238bd274ce6a1934e2e8fd26e527d3e6d63067854d5af239d62bb2b149f6dd28ee8db7a\
9dc6b123c5083a5085aeb9fd4ca5071f50ee53ad37311f23da7a2029892ddcf40177524d0ee5f27663438852a7\
041f960753cf87a397ac9cf042439f485ae643ffdf016649a46e58ae91bcdf791654f392b1d9117b81b28d8e6b\
34fef464f4542a431f69838a302df410bbcb9b3951c296fc785876c0ad184bacca4f9c9975ca297f8d6f5d3a4f\
0858d0510749a69e4bbf0762bf8a2ddffc8cca5356de9e6ced3224482522c8a6681f47e6b496e353b86f7f0049\
af1573411e88fbf6e67f87fc6fcbc9738904c5b60786e71a2b0fe3f9251416939d19033cc67b695966ab4b50a7\
d68660ecfd8dad0a7f907927d7d6f565ac8681d1e26afeb179ef19d89f5c492936a8fe8fd22d9721d4beb6b299\
0ad14c2e211aeacaf749ace45f476e7c2e35e9212b3f05969f47a77cf95bcfba6cd7aa2b58aae951749d7a4f91\
bc44e4a1199b853acb62e0a92e0cac60004e05c39d99448bb149d00a7de6d60c99cddca4485e1b3155caed0581\
933bf7aff192fdf7fa57362227efe5b169cc9236918e2#25000",
Greater,
);
test(
"0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863\
326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190\
307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095\
326366642654104239157814952043740430385500801944170641671518644712839968171784546957026271\
631064546150257207402481637773389638550695260668341137273873722928956493547025762652098859\
693201965058554764703306793654432547632744951250406069438147104689946506220167720424524529\
612687946546193165174681392672504103802546259656869144192871608293803172714367782654877566\
485085674077648451464439940461422603193096735402574446070308096085047486638523138181676751\
438667476647890881437141985494231519973548803751658612753529166100071053558249879414729509\
293113897155998205654392871700072180857610252368892132449713893203784393530887748259701715\
591070882368362758984258918535302436342143670611892367891923723146723217205340164925687274\
778234453534764811494186423867767744060695626573796008670762571991847340226514628379048830\
620330611446300737194890027436439650025809365194430411911506080948793067865158870900605203\
468429736193841289652556539686022194122924207574321757489097706752687115817051137009158942\
665478595964890653058460258668382940022833005382074005677053046787001841624044188332327983\
863490015631218895606505531512721993983320307514084260914790012651682434438935724727882054\
862715527418772430024897945401961872339808608316648114909306675193393128904316413706813977\
764981769748689038877899912965036192707108892641052309247839173735012298424204995689359922\
066022046549415106139187885744245577510206837030866619480896412186807790208181588580001688\
115973056186676199187395200766719214592236720602539595436541655311295175989940056000366513\
567569051245926825743946483168332624901803824240824231452306140963805700702551387702681785\
163069025513703234053802145019015374029509942262995779647427138157363801729873940704242179\
972266962979939312706935747240493386530879758721699645129446491883771156701678598804981838\
896784134938314014073166472765327635919233511233389338709513209059272185471328975470797891\
384445466676192702885533423429899321803769154973340267546758873236778342916191810430116091\
695265547859732891763545556742863877463987101912431754255888301206779210280341206879759143\
081283307230300883494705792496591005860012341561757413272465943068435465211135021544341539\
955381856522750221424566440006276183303206472725721975152908278568421320795988638967277119\
552218819046603957009774706512619505278932296088931405625433442552392062030343941777357945\
592125901992559114844024239012554259003129537051922061506434583787873002035414421785758013\
236451660709914383145004985896688577222148652882169418127048860758972203216663128378329156\
763074987298574638928269373509840778049395004933998762647550703162216139034845299424917248\
373406136622638349368111684167056925214751383930638455371862687797328895558871634429756244\
755392366369488877823890174981027356552405051854773061944052423221255902483308277888889059\
629119729954574415624512485926831126074679728163809025000565599914612833254358111404848206\
064082422479240385576476235031100324259709142501114615584830670012583182191534720747411194\
009835573272826144273821397070477956259670579023033848061713455553685537581065749734447922\
511196546161827896010068512965395479658663783522473624546093585036050678414391144523145778\
033591792112795570505555451438788818815351948593446724642949864050626518424475395663783373\
482207533294481306493360354610101774649326787716719861207396832012359607729024683045940313\
056377631324010804202854359026945094030740014933950767316028502869730318718239984335257435\
499560850256608978339556421149480733936260751023818331411004708903950134330297413474840540\
615877539688838154076980177673036999107492469784784312843036411289202801227256346839162335\
478772734006395865717981906935812738703433531318905038384561644444292796906383796909244130\
396560098766358462776607605348697490859381193930925179119885552776535666076243935687719423\
316664283820074481630786522923565982658627591874752087509144760901697356935723182424991947\
549443163146339227074324459030248254441249035940990071137732631099807772393757909266778722\
629956777375912526875469176039550147363373746164507645777159814661075839930304323134949658\
648228467849524754029796890015109842434081672264105346517531889570934146265891398017312367\
624887458550269961924667805242588237899590714418575355951901931382627559350018482608107690\
649406792443588583150352601704500934671408738472789516784541525226702369690546869844607210\
982177473660654752324208906381768833565330834542905202366217368168902181009185927011641625\
633710921091919381108840837199549413952808743847659331516464524483714349554707176747864466\
777777326240059944280388300505206396025448722194010048245683558491411637202165014829048895\
410548598858213914673928012796078376579803019019789583129844584235055162804713845709836714\
317959849798338493664305135743977846408028394499649283617720121752971960111518923347566466\
448721470400595270020824797119629125957079132287525024225275228566313043051121949377154294\
071049224714797815453298506882289269488223421814177347791228970593038516786441235127732137\
994705131308656152609176742141289789979427710841049555905492995846031292895641072337934722\
198262960246577885985564915354252627693645781715768750562769595194061476951336213589662110\
367239018618344910084705602324088574073649806491335049772722985412155992256490590320416580\
077713036548444879098580291680677229873848480539143712688284515899628929046495360697649132\
264972901758104649039660124902680914422669630653224053279318052013899030250670164594614509\
327899187497505884595089281231314653584115645478628887671179275944418910322703397269941078\
262094906693919323364952884039841053417413103028429829838459727450968915350522980623244092\
313811057843565473409867519383860728240789752379906522153682844964151952043614300234064117\
767172081947074281247061607867913971425756102687732567256651877939886954356124725250382411\
053283794249496242507538598556613018763256646372669528189918244702833606445833764694631343\
231391442353011806085264453177417782916531986887710748380021596407193754688536272412072273\
614121001398409439077271839347179202289574189656209567797703954759527223382789190943695895\
614158188376085603483406338490640117359928489718961165535088120722916741671690288281106170\
437298078875517486927574003575530600731535192433495073405019379393181058876745283523641652\
769037165174922445962524406132602153314802427296962267777134506420535515102483106108876726\
629451191094581700171713511729989002590464476306635972419905184702491108868012469419154965\
444117599593375386786153288510505548595751905282992674597480577669500349660023924891175760\
577638982565055972857097146238213646128157569963142474337595314709506808920446151687031940\
548311378504976842184577809636035835677681422980401513058803221388700614366646619515456264\
282679790058090702331294425627292449298306949592915813177571423046824694868577263140819266\
749297725397437563652031075562027651175474076728453283199975064855371567852134047920526615\
350261511503564062518917498983525295760711861189703198758379508658212447144855480989097132\
278411043616321505445618925641568648009768752717279363166235676934305070540096078529757697\
334781633978650356344759608311305891874108877547649896614076709354009928967903300519712922\
929465590881315509379231165267624820097425532050135108830403411501866862817278444851832099\
989311381048011484736433826155047482700010272787155537960762697763",
"0x0.b17217f7d1cf79abc9e3b39803f2f6af40f343267298b62d8a0d175b8baafa2be7b876206debac9855955\
2fb4afa1b10ed2eae35c138214427573b291169b8253e96ca16224ae8c51acbda11317c387eb9ea9bc3b136603\
b256fa0ec7657f74b72ce87b19d6548caf5dfa6bd38303248655fa1872f20e3a2da2d97c50f3fd5c607f4ca11f\
b5bfb90610d30f88fe551a2ee569d6dfc1efa157d2e23de1400b39617460775db8990e5c943e732b479cd33ccc\
c4e659393514c4c1a1e0bd1d6095d25669b333564a3376a9c7f8a5e148e82074db6015cfe7aa30c480a5417350\
d2c955d5179b1e17b9dae313cdb6c606cb1078f735d1b2db31b5f50b5185064c18b4d162db3b365853d7598a19\
51ae273ee5570b6c68f96983496d4e6d330af889b44a02554731cdc8ea17293d1228a4ef98d6f5177fbcf07552\
68a5c1f9538b98261affd446b1ca3cf5e9222b88c66d3c5422183edc99421090bbb16faf3d949f236e02b20cee\
886b905c128d53d0bd2f9621363196af503020060e49908391a0c57339ba2beba7d052ac5b61cc4e9207cef2f0\
ce2d7373958d7622658901e646a95184460dc4e7487156e0c292413d5e361c1696dd24aaebd473826fda0c238b\
90ab111bbbd67c724972cd18bfbbd9d426c472096e76115c05f6f7cebac9f45aececb72f19c38339d8f6826250\
dea891ef07afff3a892374e175eb4afc8daadd885db6ab03a49bd0dc0b1b31d8a0e23fac5e5767df95884e0642\
5a41526fac51c3ea8449fe8f70edd062b1a63a6c4c60c52ab33161e238438897a39ce78b63c9f364f5b8aef22e\
c2fee6e0850eca42d06fb0c75df5497e00c554b03d7d2874a000ca8f58d94f0341cbe2ec92156c9f949db4a931\
6f281501e53daec3f64f1b783154c60320e2ff79333ce3573facc5fdcf11785903155bbd90f023b220224fcd84\
71bf4f445f0a88a14f0cd976ea354bb20cdb5ccb3db239288d586554e2a0e8a6fe51a8cfaa72ef2ad8a43dc421\
2b210b779dfe49d7307cc846532e4b9694edad162af053b1751f3a3d091f65665815412b5e8c202461069ac14b\
958784934b8d6cce1daa50537011aa4fb42b9a3def41bda1f85ef6fdbf2f2d89d2a4b1835278fd9405789f4568\
12b552879a6168695c12963b0ff01eaab73e5b5c1585318e7624f14a51a4a026b6808292057fd99b66dc085a98\
ac8d8caf9eeeea98a2400cac95f260fd10036f9f91096ac3195220a1a356b2a73b7eaadaf6d605871ef7afb80b\
c423433562e94b12dfab414451579df59eae0517070624012a82962c59cab347f8304d889659e5a9139db14efc\
c30852be3e8fc99f14d1d822dd6e2f76797e30219c8aa9ce8848a886eb3c87b7295988012e8314186edbaf8685\
6ccd3c3b6ee94e62f110a6783d2aae89ccc3b76fc435a0ce134c2838fd571ec6c1366a992cbb9ac407ddb6c13a\
4b8d1ecf7567eb0971cc90b5518569f144e67ebe9b42698fea79d89d5c5ed40ac5e3701d7d7725377cf0656907\
fb9b1b16ea8911afbf1ae5a66203d62fd1e7093435b9c277736a70fa8601cf6868a055b2238677a2bfbbd843bf\
a1873f0c446b01b2ae0e98e0e1527a900b1af5e75f87c7cd17af804d933d6f7e1b9e1903d71c7bba0281137609\
0dd617335dfdd424f2b661cd85063034e341b06e211977b075a8b7808df43bd8eef1fd9678cc0b5e9f60a3eb81\
747f87e5709468d78ebd2da0116e6b65aeb3be77ee236fdc33bc8e7df1ffc2e2288f8ca9aee5b60899d52247f4\
ce0b6ffd8b947817642c6f224f70f88255e1c0839cbcbdd826c5d3770067e3e08eb679c1db7ffc1684223d7c6e\
68115a2832291ff14fc9db25da9beccb4c27533e747d9047f55c901aff64a09c45be2c73e6fdc29696e2268a5e\
0c92f518195dbbd18c4ef702d6c5501316ded1f3e5585f6ddd13a05954694870e71c194cbc43962e112ee67990\
c36312177d1b7b1a769f887324b53de1a4c99c9a092c106c3ce35b948cb5253d66ae99d7efbea3d9e7f586217a\
eb4068aeede384fa88b87fd036381a74342da7a6ed2658adea5ee414cbc1bb5f505d220a7043a0742281b03f81\
fc6473930ff7c847e90a373f5a9a527bd4447adb7d19c45e2715d3d15c298570b152cec2fbd582dc46ae726e49\
e3c7c334b5efdb4c6fa4507ba0026761a680b77f6cab5ed376d105839f0319222be8fdb6792689ff158a59908f\
1670776738af20f3ccf6d582ba8c6120da6a649a55783ce134a42bbafae7dac1d5387bf018d2b3101223478592\
8dcdb041e9325b4af621a8a555e276a3141f601e3bd2bcb9856b29fadc8ec1b2f45a16299e5acfa4d768ee2fe5\
27157ffcd4a70aa1edf6410110bd615e257a203f76ed0e79070d20a751fcc43a7c41179057fc450dca7a902478\
4be09f609eec90443850aca3bed5f3d14af707bb095af931cf8317d02a3734ad2cc114bff03d0604a998e01950\
b82e686ce94a838ee11689688d0fd967d06bda5b72aa613fa220bbdec995c53efade356ed90b7a943fd280fce7\
df51d607b1b85535b4ce9343f671d4877fc7194ccc4cdfefc08ea6da24640bbe2ba0f2b9f73ad3dda756093224\
7ff56563467f32018e14fe46c75a44a4d5d7e8dab6bb6dbf8bc4e6d07f9e7d993d89957238157fbeffa0345b5a\
ab3d1feedcb09f14c40257b2b7f308eb799ab4c95d1a1ed94bdda0b625f39c4c86fc5ee5748041d647aefcb7af\
226fe1382997d87b22199e912c3e3f53db5a7208e0352bb66b379778cee2ec9af2d8731119f38bd9d90d43e054\
d8b71fc0c0d10990e84c33202ecc9fed51f626393ccc566840367ae0b74cb4dbfe4cebd7fe74b8de2aa9176bdb\
500613ee2ac34e4e9e787b4c29e7fb208a9dd9c92f002ca30f833f56093c1848bde22a0bdad1022218095f2b86\
3b06cca879f0bc8d773a5281eefa811774a6664b9f1b12a25c54eb9d907735d441c77e8427cda02b7508d45495\
b4ec1b2e6b85e8d751a8f7dd271ee0ec8dce8b63596533fc241fe15a9cfa5abd5735aed99937f7409369a1b263\
21bd1350ecbf21c454c1da119c71216d73e8ec5dd5c59279d16f2d3ff8447cd6acd1f8d6b54719549a7c2bb38a\
ef7e67c2008bcd78924ba5575dbae31f6549f337c9c24490704a3440c513ef2b9c730c6f64c031c913b8186c5e\
e43a2627ef452a94358b26965a848d4129af72ed3b4ec0d1a2060620067862b47def36ea66bc481a43268778c0\
e176d3a2f7c12a69dd654314afca207a0c1f900a2c7acb9aa695870193103d887b8d0d16bff66229b1d5c71e40\
bb196e5a5a87aea56001f36aa98b34a9353f8875ca66fcf6e80ebeb0c22fc511040d766f38a91d18eb2c5f02e9\
aaaaed8daf49bdc90a7c8117aa4acc8a60289ca3cb5b54457e1391c8f7d31054e5b58f50ac76ec56620cca6489\
72f6dc08e00ce59d5db3a89085024a9b4bf7fb013eca92e5c1c8368f1d8c13d87b377e6f3ca18060afe2542be4\
1c483be5dca1a3fc10cc465da6274043827967604f409a1fbaeb8a5e4f1fe5441d28643fd2d6d64da55b746a4f\
3d2187efade66c0bf8edb271e34d71ad43d43e5baca7f769e2ba1c272a49de81910e8b602e9671be82031491d7\
4fb17051bdb411a86c5897c133a47485597eea69d95a1268bfe491409e6e3f9d2aa2dfb5570097ee1d42c07ee5\
a2d673dd9acad6b0269394056c80dc2b5b6c239b355a0bfaaa4d8b12b86f427b5bfc159f12d2732fb9d536b062\
e904d70a78ae88f142d2757adef783b74a76c7e2ad84562a478e08a978dcc2c0ee3b60d5ab43fed286d8ac992c\
9918e5f2322e22ea48d7de9504546fe523cf59f15d57e0c6a27c009cba92fdd34515ad0219648651fec8951ef2\
4cd15f0768d8e8bfc8bfdb1cc86754bd0323de06922b8aabf3fe75820360a5429d9f25bd5fc8e8eac201f37562\
7aa36b8f27de0ca84dc4336e0d447dfa2110dc08906a14e9d85949af3598f5e655e163cab1591dad6f6e8647cb\
9c1d83fbbf59224a0dd883c2b04532ba544ab77907c6a64e0b3d670ac71233841a343342398055859b97d529a9\
860ddf109cf8b7caa505d4db83c22a3891b3757f5b43786250edc717ff1c7edd3c8103fa001753fde36b834e14\
d3cc3b34f4723245a9edb3ac225e3ed7f4bb3ed1887d9c4ef8fcd34f8b4a6f972c2f06ba8d4921d51ffb02831a\
6313260eda6004216e17946dfafe1c52cba834173142b53fd25789b0b07450d4177f4b304961f5822e8b45db09\
75f0bdf4e5c8f91d544c989814a7e886a72643bd5140510dcb924c1c93aefe60f539c864f95518e85c4710c085\
e8f778c24d2ce70b69e4c61b715d897bb3063fab3122d0bf7e1488b57ee5822a55d8d0afa46cdeec391d6881a0\
dc4d3ea6523ba5b98039ca963a1e0f72cb6259a13d6e3e52ec#25020",
25000,
Nearest,
"2.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000",
"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000#25000",
Greater,
);
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_exp() {
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_exp(x)), NiceFloat(out));
}
test::<f32>(f32::NAN, f32::NAN);
test::<f32>(f32::INFINITY, f32::INFINITY);
test::<f32>(f32::NEGATIVE_INFINITY, 0.0);
test::<f32>(0.0, 1.0);
test::<f32>(-0.0, 1.0);
test::<f32>(1.0, core::f32::consts::E);
test::<f32>(-1.0, 0.36787945);
test::<f32>(0.5, 1.6487212);
test::<f32>(-0.5, 0.60653067);
test::<f32>(2.0, 7.389056);
test::<f32>(-2.0, 0.13533528);
test::<f32>(core::f32::consts::PI, 23.140696);
test::<f32>(-core::f32::consts::PI, 0.043213915);
test::<f32>(core::f32::consts::E, 15.154261);
test::<f32>(-core::f32::consts::E, 0.06598804);
test::<f64>(f64::NAN, f64::NAN);
test::<f64>(f64::INFINITY, f64::INFINITY);
test::<f64>(f64::NEGATIVE_INFINITY, 0.0);
test::<f64>(0.0, 1.0);
test::<f64>(-0.0, 1.0);
test::<f64>(1.0, core::f64::consts::E);
test::<f64>(-1.0, 0.36787944117144233);
test::<f64>(0.5, 1.6487212707001282);
test::<f64>(-0.5, 0.6065306597126334);
test::<f64>(2.0, 7.38905609893065);
test::<f64>(-2.0, 0.1353352832366127);
test::<f64>(core::f64::consts::PI, 23.140692632779267);
test::<f64>(-core::f64::consts::PI, 0.04321391826377226);
test::<f64>(core::f64::consts::E, 15.154262241479262);
test::<f64>(-core::f64::consts::E, 0.06598803584531254);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_exp_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 e = primitive_float_exp(x);
assert_eq!(e.is_nan(), x.is_nan());
assert!(e.is_nan() || e >= T::ZERO);
});
}
#[test]
fn primitive_float_exp_properties() {
apply_fn_to_primitive_floats!(primitive_float_exp_properties_helper);
}
#[test]
#[allow(clippy::type_repetition_in_bounds)]
fn test_primitive_float_exp_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 u = Rational::from_str(s).unwrap();
assert_eq!(NiceFloat(primitive_float_exp_rational(&u)), NiceFloat(out));
}
test::<f32>("0", 1.0);
test::<f32>("1", core::f32::consts::E);
test::<f32>("1/2", 1.6487212);
test::<f32>("1/3", 1.3956125);
test::<f32>("22/7", 23.169971);
test::<f32>("1000000", f32::INFINITY);
test::<f32>("1/1000000", 1.000001);
test::<f32>("-1", 0.36787945);
test::<f32>("-1/2", 0.60653067);
test::<f32>("-1/3", 0.71653134);
test::<f32>("-22/7", 0.04315931);
test::<f32>("-1000000", 0.0);
test::<f64>("0", 1.0);
test::<f64>("1", core::f64::consts::E);
test::<f64>("1/2", 1.6487212707001282);
test::<f64>("1/3", 1.3956124250860895);
test::<f64>("22/7", 23.16997229826248);
test::<f64>("1000000", f64::INFINITY);
test::<f64>("1/1000000", 1.0000010000005);
test::<f64>("-1", 0.36787944117144233);
test::<f64>("-1/2", 0.6065306597126334);
test::<f64>("-1/3", 0.7165313105737893);
test::<f64>("-22/7", 0.043159309261452596);
test::<f64>("-1000000", 0.0);
}
#[allow(clippy::type_repetition_in_bounds)]
fn primitive_float_exp_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 y = primitive_float_exp_rational::<T>(&x);
assert!(y >= T::ZERO);
if x > 0u32 {
assert!(y >= T::ONE);
} else if x < 0u32 {
assert!(y <= T::ONE);
}
});
primitive_float_gen::<T>().test_properties(|x| {
if x.is_finite() {
assert_eq!(
NiceFloat(primitive_float_exp_rational::<T>(&Rational::exact_from(x))),
NiceFloat(primitive_float_exp(x))
);
}
});
}
#[test]
fn primitive_float_exp_rational_properties() {
apply_fn_to_primitive_floats!(primitive_float_exp_rational_properties_helper);
}
#[test]
fn exp_prec_round_fail() {
const THREE: Float = Float::const_from_unsigned(3);
assert_panic!(Float::one_prec(1).exp_prec_round(0, Floor));
assert_panic!(Float::one_prec(1).exp_prec_round_ref(0, Floor));
assert_panic!({
let mut x = Float::one_prec(1);
x.exp_prec_round_assign(0, Floor)
});
assert_panic!(THREE.exp_prec_round(1, Exact));
assert_panic!(THREE.exp_prec_round_ref(1, Exact));
assert_panic!({
let mut x = THREE;
x.exp_prec_round_assign(1, Exact)
});
}
#[test]
fn exp_round_fail() {
const THREE: Float = Float::const_from_unsigned(3);
assert_panic!(THREE.exp_round(Exact));
assert_panic!(THREE.exp_round_ref(Exact));
assert_panic!({
let mut x = THREE;
x.exp_round_assign(Exact);
});
}
#[test]
fn exp_prec_fail() {
assert_panic!(Float::NAN.exp_prec(0));
assert_panic!(Float::NAN.exp_prec_ref(0));
assert_panic!({
let mut x = Float::NAN;
x.exp_prec_assign(0)
});
}
#[allow(clippy::needless_pass_by_value)]
fn exp_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {
let (e, o) = x.clone().exp_prec_round(prec, rm);
assert!(e.is_valid());
let (e_alt, o_alt) = x.exp_prec_round_ref(prec, rm);
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.exp_prec_round_assign(prec, rm);
assert!(x_alt.is_valid());
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_e, rug_o) = rug_exp_prec_round(&rug::Float::exact_from(&x), prec, rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_e)),
ComparableFloatRef(&e)
);
assert_eq!(rug_o, o);
}
assert!(e.is_nan() || e.is_sign_positive());
if e.is_normal() {
assert_eq!(e.get_prec(), Some(prec));
}
if o == Equal {
for rm2 in exhaustive_rounding_modes() {
let (e2, o2) = x.exp_prec_round_ref(prec, rm2);
assert_eq!(
ComparableFloat(e2.abs_negative_zero_ref()),
ComparableFloat(e.abs_negative_zero_ref())
);
assert_eq!(o2, Equal);
}
} else {
assert_panic!(x.exp_prec_round_ref(prec, Exact));
}
}
#[test]
fn exp_prec_round_properties() {
float_unsigned_rounding_mode_triple_gen_var_36().test_properties(|(x, prec, rm)| {
exp_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (e, o) = Float::NAN.exp_prec_round(prec, rm);
assert!(e.is_nan());
assert_eq!(o, Equal);
assert_eq!(
Float::INFINITY.exp_prec_round(prec, rm),
(Float::INFINITY, Equal)
);
assert_eq!(
Float::NEGATIVE_INFINITY.exp_prec_round(prec, rm),
(Float::ZERO, Equal)
);
assert_eq!(
Float::ZERO.exp_prec_round(prec, rm),
(Float::one_prec(prec), Equal)
);
assert_eq!(
Float::NEGATIVE_ZERO.exp_prec_round(prec, rm),
(Float::one_prec(prec), Equal)
);
});
}
#[test]
fn exp_prec_round_properties_exp_3() {
let mut config = GenConfig::new();
config.insert("mean_small_n", 50000);
config.insert("mean_precision_n", 256);
config.insert("mean_exponent_n", 4);
float_unsigned_rounding_mode_triple_gen_var_36().test_properties_with_config(
&config,
|(x, prec, rm)| {
exp_prec_round_properties_helper(x, prec, rm);
},
);
}
#[test]
fn exp_round_properties() {
float_rounding_mode_pair_gen_var_47().test_properties(|(x, rm)| {
let (e, o) = x.clone().exp_round(rm);
assert!(e.is_valid());
let (e_alt, o_alt) = x.exp_round_ref(rm);
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.exp_round_assign(rm);
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
let (e_alt, o_alt) = x.exp_prec_round_ref(x.significant_bits(), rm);
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
assert!(e.is_nan() || e.is_sign_positive());
if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {
let (rug_e, rug_o) = rug_exp_round(&rug::Float::exact_from(&x), rug_rm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_e)),
ComparableFloatRef(&e)
);
assert_eq!(rug_o, o);
}
});
}
#[test]
fn exp_prec_properties() {
float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {
let (e, o) = x.clone().exp_prec(prec);
assert!(e.is_valid());
let (e_alt, o_alt) = x.exp_prec_ref(prec);
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
let mut x_alt = x.clone();
let o_alt = x_alt.exp_prec_assign(prec);
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
let (e_alt, o_alt) = x.exp_prec_round_ref(prec, Nearest);
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert_eq!(o_alt, o);
assert!(e.is_nan() || e.is_sign_positive());
if e.is_normal() {
assert_eq!(e.get_prec(), Some(prec));
}
let (rug_e, rug_o) = rug_exp_prec(&rug::Float::exact_from(&x), prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_e)),
ComparableFloatRef(&e)
);
assert_eq!(rug_o, o);
});
}
#[allow(clippy::needless_pass_by_value)]
fn exp_properties_helper(x: Float) {
let e = x.clone().exp();
assert!(e.is_valid());
let e_alt = (&x).exp();
assert!(e_alt.is_valid());
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
let mut x_alt = x.clone();
x_alt.exp_assign();
assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&e));
let e_alt = x.exp_round_ref(Nearest).0;
assert_eq!(ComparableFloatRef(&e_alt), ComparableFloatRef(&e));
assert!(e.is_nan() || e.is_sign_positive());
let rug_e = Float::from(&rug_exp(&rug::Float::exact_from(&x)));
assert_eq!(ComparableFloatRef(&rug_e), ComparableFloatRef(&e));
}
#[test]
fn exp_properties() {
float_gen().test_properties(exp_properties_helper);
}
#[test]
fn exp_properties_exp_3() {
let mut config = GenConfig::new();
config.insert("mean_precision_n", 40000);
config.insert("mean_exponent_n", 4);
float_gen().test_properties_with_config(&config, exp_properties_helper);
}
#[test]
fn test_exp_rational_prec() {
let test = |s, prec, out: &str, out_hex: &str, out_o| {
let x = Rational::from_str(s).unwrap();
let (f, o) = Float::exp_rational_prec(x.clone(), prec);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
let (f, o) = Float::exp_rational_prec_ref(&x, prec);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
};
test("0", 1, "1.0", "0x1.0#1", Equal);
test("0", 10, "1.0000", "0x1.000#10", Equal);
test("0", 53, "1.0000000000000000", "0x1.0000000000000#53", Equal);
test("1", 1, "2.0", "0x2.0#1", Less);
test("1", 10, "2.7188", "0x2.b8#10", Greater);
test("1", 53, "2.7182818284590451", "0x2.b7e151628aed2#53", Less);
test("-1", 1, "0.25", "0x0.4#1", Less);
test("-1", 10, "0.36768", "0x0.5e2#10", Less);
test(
"-1",
53,
"0.36787944117144233",
"0x0.5e2d58d8b3bce0#53",
Greater,
);
test("1/2", 1, "2.0", "0x2.0#1", Greater);
test("1/2", 10, "1.6484", "0x1.a60#10", Less);
test(
"1/2",
53,
"1.6487212707001282",
"0x1.a61298e1e069c#53",
Greater,
);
test("-1/2", 1, "0.50", "0x0.8#1", Less);
test("-1/2", 10, "0.60645", "0x0.9b4#10", Less);
test(
"-1/2",
53,
"0.60653065971263342",
"0x0.9b4597e37cb050#53",
Greater,
);
test("1/3", 1, "1.0", "0x1.0#1", Less);
test("1/3", 10, "1.3965", "0x1.658#10", Greater);
test(
"1/3",
53,
"1.3956124250860895",
"0x1.6546db1ba2d13#53",
Less,
);
test("-1/3", 1, "0.50", "0x0.8#1", Less);
test("-1/3", 10, "0.71680", "0x0.b78#10", Greater);
test(
"-1/3",
53,
"0.71653131057378927",
"0x0.b76e9891797528#53",
Greater,
);
test("22/7", 1, "16.0", "0x1.0E+1#1", Less);
test("22/7", 10, "23.156", "0x17.28#10", Less);
test(
"22/7",
53,
"23.169972298262479",
"0x17.2b834df64368#53",
Less,
);
test("-22/7", 1, "0.031", "0x0.08#1", Less);
test("-22/7", 10, "0.043152", "0x0.0b0c#10", Less);
test(
"-22/7",
53,
"0.043159309261452596",
"0x0.0b0c7d0dcbbf5e8#53",
Less,
);
test("2", 1, "8.0", "0x8.0#1", Greater);
test("2", 10, "7.3906", "0x7.64#10", Greater);
test(
"2",
53,
"7.3890560989306504",
"0x7.63992e35376b8#53",
Greater,
);
test("-2", 1, "0.12", "0x0.2#1", Less);
test("-2", 10, "0.13525", "0x0.22a#10", Less);
test(
"-2",
53,
"0.13533528323661270",
"0x0.22a555477f0398#53",
Greater,
);
test("100", 1, "2.2e43", "0x1.0E+36#1", Less);
test("100", 10, "2.6874e43", "0x1.348E+36#10", Less);
test(
"100",
53,
"2.6881171418161356e43",
"0x1.3494a9b171bf5E+36#53",
Greater,
);
test("-100", 1, "4.5e-44", "0x1.0E-36#1", Greater);
test("-100", 10, "3.7222e-44", "0xd.48E-37#10", Greater);
test(
"-100",
53,
"3.7200759760208361e-44",
"0xd.460f8a7157ae8E-37#53",
Greater,
);
let test_big = |x: Rational, prec, out: &str, out_hex: &str, out_o| {
let (f, o) = Float::exp_rational_prec(x.clone(), prec);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
let (f, o) = Float::exp_rational_prec_ref(&x, prec);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
};
test_big(
Rational::from(1_000_000_000),
1,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::from(1_000_000_000),
10,
"Infinity",
"Infinity",
Greater,
);
test_big(-Rational::from(1_000_000_000), 1, "0.0", "0x0.0", Less);
test_big(-Rational::from(1_000_000_000), 10, "0.0", "0x0.0", Less);
test_big(
Rational::power_of_2(1000i64),
1,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::power_of_2(1000i64),
10,
"Infinity",
"Infinity",
Greater,
);
test_big(-Rational::power_of_2(1000i64), 1, "0.0", "0x0.0", Less);
test_big(-Rational::power_of_2(1000i64), 10, "0.0", "0x0.0", Less);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
"1.0000",
"0x1.000#10",
Less,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
"1.0",
"0x1.0#1",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
"1.0000",
"0x1.000#10",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
1,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
10,
"1.0000",
"0x1.000#10",
Less,
);
}
#[test]
#[should_panic]
fn exp_rational_prec_fail() {
Float::exp_rational_prec(Rational::ONE, 0);
}
#[test]
#[should_panic]
fn exp_rational_prec_ref_fail() {
Float::exp_rational_prec_ref(&Rational::ONE, 0);
}
#[test]
fn test_exp_rational_prec_round() {
let test = |s, prec, rm, out: &str, out_hex: &str, out_o| {
let x = Rational::from_str(s).unwrap();
let (f, o) = Float::exp_rational_prec_round(x.clone(), prec, rm);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
let (f, o) = Float::exp_rational_prec_round_ref(&x, prec, rm);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
};
test("0", 1, Floor, "1.0", "0x1.0#1", Equal);
test("0", 1, Ceiling, "1.0", "0x1.0#1", Equal);
test("0", 1, Nearest, "1.0", "0x1.0#1", Equal);
test("0", 10, Floor, "1.0000", "0x1.000#10", Equal);
test("0", 10, Ceiling, "1.0000", "0x1.000#10", Equal);
test("0", 10, Nearest, "1.0000", "0x1.000#10", Equal);
test("1", 1, Floor, "2.0", "0x2.0#1", Less);
test("1", 1, Ceiling, "4.0", "0x4.0#1", Greater);
test("1", 1, Nearest, "2.0", "0x2.0#1", Less);
test("1", 10, Floor, "2.7148", "0x2.b7#10", Less);
test("1", 10, Ceiling, "2.7188", "0x2.b8#10", Greater);
test("1", 10, Nearest, "2.7188", "0x2.b8#10", Greater);
test("-1", 1, Floor, "0.25", "0x0.4#1", Less);
test("-1", 1, Ceiling, "0.50", "0x0.8#1", Greater);
test("-1", 1, Nearest, "0.25", "0x0.4#1", Less);
test("-1", 10, Floor, "0.36768", "0x0.5e2#10", Less);
test("-1", 10, Ceiling, "0.36816", "0x0.5e4#10", Greater);
test("-1", 10, Nearest, "0.36768", "0x0.5e2#10", Less);
test("1/2", 1, Floor, "1.0", "0x1.0#1", Less);
test("1/2", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("1/2", 1, Nearest, "2.0", "0x2.0#1", Greater);
test("1/2", 10, Floor, "1.6484", "0x1.a60#10", Less);
test("1/2", 10, Ceiling, "1.6504", "0x1.a68#10", Greater);
test("1/2", 10, Nearest, "1.6484", "0x1.a60#10", Less);
test("-1/2", 1, Floor, "0.50", "0x0.8#1", Less);
test("-1/2", 1, Ceiling, "1.0", "0x1.0#1", Greater);
test("-1/2", 1, Nearest, "0.50", "0x0.8#1", Less);
test("-1/2", 10, Floor, "0.60645", "0x0.9b4#10", Less);
test("-1/2", 10, Ceiling, "0.60742", "0x0.9b8#10", Greater);
test("-1/2", 10, Nearest, "0.60645", "0x0.9b4#10", Less);
test("1/3", 1, Floor, "1.0", "0x1.0#1", Less);
test("1/3", 1, Ceiling, "2.0", "0x2.0#1", Greater);
test("1/3", 1, Nearest, "1.0", "0x1.0#1", Less);
test("1/3", 10, Floor, "1.3945", "0x1.650#10", Less);
test("1/3", 10, Ceiling, "1.3965", "0x1.658#10", Greater);
test("1/3", 10, Nearest, "1.3965", "0x1.658#10", Greater);
test("22/7", 1, Floor, "16.0", "0x1.0E+1#1", Less);
test("22/7", 1, Ceiling, "32.0", "0x2.0E+1#1", Greater);
test("22/7", 1, Nearest, "16.0", "0x1.0E+1#1", Less);
test("22/7", 10, Floor, "23.156", "0x17.28#10", Less);
test("22/7", 10, Ceiling, "23.188", "0x17.30#10", Greater);
test("22/7", 10, Nearest, "23.156", "0x17.28#10", Less);
test("-22/7", 1, Floor, "0.031", "0x0.08#1", Less);
test("-22/7", 1, Ceiling, "0.062", "0x0.1#1", Greater);
test("-22/7", 1, Nearest, "0.031", "0x0.08#1", Less);
test("-22/7", 10, Floor, "0.043152", "0x0.0b0c#10", Less);
test("-22/7", 10, Ceiling, "0.043213", "0x0.0b10#10", Greater);
test("-22/7", 10, Nearest, "0.043152", "0x0.0b0c#10", Less);
test("100", 1, Floor, "2.2e43", "0x1.0E+36#1", Less);
test("100", 1, Ceiling, "4.5e43", "0x2.0E+36#1", Greater);
test("100", 1, Nearest, "2.2e43", "0x1.0E+36#1", Less);
test("100", 10, Floor, "2.6874e43", "0x1.348E+36#10", Less);
test("100", 10, Ceiling, "2.6918e43", "0x1.350E+36#10", Greater);
test("100", 10, Nearest, "2.6874e43", "0x1.348E+36#10", Less);
test("-100", 1, Floor, "2.2e-44", "0x8.0E-37#1", Less);
test("-100", 1, Ceiling, "4.5e-44", "0x1.0E-36#1", Greater);
test("-100", 1, Nearest, "4.5e-44", "0x1.0E-36#1", Greater);
test("-100", 10, Floor, "3.7178e-44", "0xd.44E-37#10", Less);
test("-100", 10, Ceiling, "3.7222e-44", "0xd.48E-37#10", Greater);
test("-100", 10, Nearest, "3.7222e-44", "0xd.48E-37#10", Greater);
test("0", 10, Exact, "1.0000", "0x1.000#10", Equal);
test("-500/3", 1, Floor, "2.8e-73", "0x8.0E-61#1", Less);
test("-500/3", 1, Ceiling, "5.7e-73", "0x1.0E-60#1", Greater);
test("-500/3", 1, Nearest, "2.8e-73", "0x8.0E-61#1", Less);
let test_big = |x: Rational, prec, rm, out: &str, out_hex: &str, out_o| {
let (f, o) = Float::exp_rational_prec_round(x.clone(), prec, rm);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
let (f, o) = Float::exp_rational_prec_round_ref(&x, prec, rm);
assert!(f.is_valid());
assert_eq!(f.to_string(), out);
assert_eq!(to_hex_string(&f), out_hex);
assert_eq!(o, out_o);
};
test_big(
Rational::from(1_000_000_000),
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test_big(
Rational::from(1_000_000_000),
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::from(1_000_000_000),
1,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::from(1_000_000_000),
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test_big(
Rational::from(1_000_000_000),
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::from(1_000_000_000),
10,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test_big(
-Rational::from(1_000_000_000),
1,
Floor,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::from(1_000_000_000),
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test_big(
-Rational::from(1_000_000_000),
1,
Nearest,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::from(1_000_000_000),
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::from(1_000_000_000),
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test_big(
-Rational::from(1_000_000_000),
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test_big(
Rational::power_of_2(1000i64),
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test_big(
Rational::power_of_2(1000i64),
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::power_of_2(1000i64),
1,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::power_of_2(1000i64),
10,
Floor,
"2.0965e323228496",
"0x7.feE+268435455#10",
Less,
);
test_big(
Rational::power_of_2(1000i64),
10,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::power_of_2(1000i64),
10,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test_big(
-Rational::power_of_2(1000i64),
1,
Floor,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::power_of_2(1000i64),
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test_big(
-Rational::power_of_2(1000i64),
1,
Nearest,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::power_of_2(1000i64),
10,
Floor,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::power_of_2(1000i64),
10,
Ceiling,
"2.3826e-323228497",
"0x1.000E-268435456#10",
Greater,
);
test_big(
-Rational::power_of_2(1000i64),
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Floor,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Ceiling,
"2.0",
"0x2.0#1",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Nearest,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Floor,
"0.50",
"0x0.8#1",
Less,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Ceiling,
"1.0",
"0x1.0#1",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
1,
Nearest,
"1.0",
"0x1.0#1",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Floor,
"0.99902",
"0x0.ffc#10",
Less,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Ceiling,
"1.0000",
"0x1.000#10",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),
10,
Nearest,
"1.0000",
"0x1.000#10",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
1,
Floor,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
1,
Ceiling,
"2.0",
"0x2.0#1",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
1,
Nearest,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
10,
Floor,
"1.0000",
"0x1.000#10",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MIN_EXPONENT)) * Rational::from_unsigneds(3u8, 2),
10,
Nearest,
"1.0000",
"0x1.000#10",
Less,
);
test_big(
Rational::power_of_2(-100i64),
1,
Floor,
"1.0",
"0x1.0#1",
Less,
);
test_big(
Rational::power_of_2(-100i64),
1,
Ceiling,
"2.0",
"0x2.0#1",
Greater,
);
test_big(
Rational::power_of_2(-100i64),
1,
Nearest,
"1.0",
"0x1.0#1",
Less,
);
test_big(
-Rational::power_of_2(-100i64),
1,
Floor,
"0.50",
"0x0.8#1",
Less,
);
test_big(
-Rational::power_of_2(-100i64),
1,
Ceiling,
"1.0",
"0x1.0#1",
Greater,
);
test_big(
-Rational::power_of_2(-100i64),
1,
Nearest,
"1.0",
"0x1.0#1",
Greater,
);
test_big(
Rational::power_of_2(-100i64),
10,
Ceiling,
"1.0020",
"0x1.008#10",
Greater,
);
test_big(
-Rational::power_of_2(-100i64),
10,
Floor,
"0.99902",
"0x0.ffc#10",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
1,
Floor,
"1.0e323228496",
"0x4.0E+268435455#1",
Less,
);
test_big(
Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
1,
Ceiling,
"Infinity",
"Infinity",
Greater,
);
test_big(
Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
10,
Nearest,
"Infinity",
"Infinity",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
1,
Floor,
"0.0",
"0x0.0",
Less,
);
test_big(
-Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
1,
Ceiling,
"2.4e-323228497",
"0x1.0E-268435456#1",
Greater,
);
test_big(
-Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),
10,
Nearest,
"0.0",
"0x0.0",
Less,
);
}
#[test]
#[should_panic]
fn exp_rational_prec_round_fail_1() {
Float::exp_rational_prec_round(Rational::ONE, 0, Floor);
}
#[test]
#[should_panic]
fn exp_rational_prec_round_fail_2() {
Float::exp_rational_prec_round(Rational::ONE, 10, Exact);
}
#[test]
#[should_panic]
fn exp_rational_prec_round_ref_fail() {
Float::exp_rational_prec_round_ref(&Rational::ONE, 10, Exact);
}
#[allow(clippy::needless_pass_by_value)]
fn exp_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {
let (f, o) = Float::exp_rational_prec_round(x.clone(), prec, rm);
assert!(f.is_valid());
let (f_alt, o_alt) = Float::exp_rational_prec_round_ref(&x, prec, rm);
assert!(f_alt.is_valid());
assert_eq!(ComparableFloatRef(&f_alt), ComparableFloatRef(&f));
assert_eq!(o_alt, o);
assert!(f >= 0u32);
if let Ok(rrm) = rug_round_try_from_rounding_mode(rm) {
let (rug_f, rug_o) = rug_exp_rational_prec_round(&x, prec, rrm);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_f)),
ComparableFloatRef(&f)
);
assert_eq!(rug_o, o);
}
if f.is_normal() {
assert_eq!(f.get_prec(), Some(prec));
if x > 0u32 {
assert!(f >= 1u32);
} else if x < 0u32 {
assert!(f <= 1u32);
}
}
if o == Equal {
for rm in exhaustive_rounding_modes() {
let (s, oo) = Float::exp_rational_prec_round_ref(&x, prec, rm);
assert_eq!(
ComparableFloat(s.abs_negative_zero_ref()),
ComparableFloat(f.abs_negative_zero_ref())
);
assert_eq!(oo, Equal);
}
} else {
assert_panic!(Float::exp_rational_prec_round_ref(&x, prec, Exact));
}
}
#[test]
fn exp_rational_prec_round_properties() {
rational_unsigned_rounding_mode_triple_gen_var_10().test_properties(|(x, prec, rm)| {
exp_rational_prec_round_properties_helper(x, prec, rm);
});
unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {
let (f, o) = Float::exp_rational_prec_round(Rational::ZERO, prec, rm);
assert_eq!(ComparableFloat(f), ComparableFloat(Float::one_prec(prec)));
assert_eq!(o, Equal);
});
}
#[allow(clippy::needless_pass_by_value)]
fn exp_rational_prec_properties_helper(x: Rational, prec: u64) {
let (f, o) = Float::exp_rational_prec(x.clone(), prec);
assert!(f.is_valid());
let (f_alt, o_alt) = Float::exp_rational_prec_ref(&x, prec);
assert!(f_alt.is_valid());
assert_eq!(ComparableFloatRef(&f_alt), ComparableFloatRef(&f));
assert_eq!(o_alt, o);
let (f_alt, o_alt) = Float::exp_rational_prec_round_ref(&x, prec, Nearest);
assert_eq!(ComparableFloatRef(&f_alt), ComparableFloatRef(&f));
assert_eq!(o_alt, o);
assert!(f >= 0u32);
let (rug_f, rug_o) = rug_exp_rational_prec(&x, prec);
assert_eq!(
ComparableFloatRef(&Float::from(&rug_f)),
ComparableFloatRef(&f)
);
assert_eq!(rug_o, o);
if f.is_normal() {
assert_eq!(f.get_prec(), Some(prec));
if x > 0u32 {
assert!(f >= 1u32);
} else if x < 0u32 {
assert!(f <= 1u32);
}
}
}
#[test]
fn exp_rational_prec_properties() {
rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {
exp_rational_prec_properties_helper(x, prec);
});
unsigned_gen_var_11().test_properties(|prec| {
let (f, o) = Float::exp_rational_prec(Rational::ZERO, prec);
assert_eq!(ComparableFloat(f), ComparableFloat(Float::one_prec(prec)));
assert_eq!(o, Equal);
});
}
#[test]
fn test_exp_overflow_sliver_regression() {
let x = Float::ln_2_prec_round(200, Up)
.0
.mul_prec_round(Float::exact_from(i64::from(Float::MAX_EXPONENT)), 200, Up)
.0;
assert!(
Rational::exact_from(&x)
>= Rational::exact_from(Float::ln_2_prec_round(500, Ceiling).0)
* Rational::from(Float::MAX_EXPONENT)
);
let (v, o) = x.exp_prec_round_ref(25000, Nearest);
assert!(v.is_infinite());
assert_eq!(o, Greater);
let (v, o) = x.exp_prec_round_ref(25000, Floor);
assert!(!v.is_infinite());
assert_eq!(v.get_exponent(), Some(Float::MAX_EXPONENT));
assert_eq!(o, Less);
}