summaryrefslogtreecommitdiff
path: root/libc/math
diff options
context:
space:
mode:
Diffstat (limited to 'libc/math')
-rw-r--r--libc/math/Makefile2
-rwxr-xr-xlibc/math/gen-libm-test.pl4
-rw-r--r--libc/math/libm-test.inc570
-rw-r--r--libc/math/s_ccosh.c20
-rw-r--r--libc/math/s_ccoshf.c20
-rw-r--r--libc/math/s_ccoshl.c20
-rw-r--r--libc/math/s_cexp.c20
-rw-r--r--libc/math/s_cexpf.c20
-rw-r--r--libc/math/s_cexpl.c20
-rw-r--r--libc/math/s_clog.c13
-rw-r--r--libc/math/s_clog10.c13
-rw-r--r--libc/math/s_clog10f.c13
-rw-r--r--libc/math/s_clog10l.c13
-rw-r--r--libc/math/s_clogf.c13
-rw-r--r--libc/math/s_clogl.c13
-rw-r--r--libc/math/s_csin.c20
-rw-r--r--libc/math/s_csinf.c20
-rw-r--r--libc/math/s_csinh.c20
-rw-r--r--libc/math/s_csinhf.c20
-rw-r--r--libc/math/s_csinhl.c20
-rw-r--r--libc/math/s_csinl.c20
-rw-r--r--libc/math/s_ctan.c11
-rw-r--r--libc/math/s_ctanf.c10
-rw-r--r--libc/math/s_ctanh.c11
-rw-r--r--libc/math/s_ctanhf.c10
-rw-r--r--libc/math/s_ctanhl.c11
-rw-r--r--libc/math/s_ctanl.c11
27 files changed, 919 insertions, 39 deletions
diff --git a/libc/math/Makefile b/libc/math/Makefile
index c390d5511..5491c5b83 100644
--- a/libc/math/Makefile
+++ b/libc/math/Makefile
@@ -60,7 +60,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos \
s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \
- s_isinf_ns $(calls:s_%=m_%)
+ s_isinf_ns $(calls:s_%=m_%) x2y2m1
include ../Makeconfig
diff --git a/libc/math/gen-libm-test.pl b/libc/math/gen-libm-test.pl
index c2c22a5b1..5d9b2ea4b 100755
--- a/libc/math/gen-libm-test.pl
+++ b/libc/math/gen-libm-test.pl
@@ -323,7 +323,9 @@ sub parse_args {
}
# Special handling for some macros:
$cline .= " (\"$str\", ";
- if ($args[0] =~ /fpclassify|isnormal|isfinite|signbit/) {
+ if ($args[0] =~ /fpclassify|isnormal|isfinite|isinf|isnan|signbit
+ |isgreater|isgreaterequal|isless|islessequal
+ |islessgreater|isunordered/x) {
$c_call = "$args[0] (";
} else {
$c_call = " FUNC($args[0]) (";
diff --git a/libc/math/libm-test.inc b/libc/math/libm-test.inc
index 83d58998f..df860ebe2 100644
--- a/libc/math/libm-test.inc
+++ b/libc/math/libm-test.inc
@@ -40,13 +40,13 @@
/* This testsuite has currently tests for:
acos, acosh, asin, asinh, atan, atan2, atanh,
cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
- fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
+ fabs, fdim, finite, floor, fma, fmax, fmin, fmod, fpclassify,
frexp, gamma, hypot,
ilogb, isfinite, isinf, isnan, isnormal,
isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
j0, j1, jn,
ldexp, lgamma, log, log10, log1p, log2, logb,
- modf, nearbyint, nextafter,
+ modf, nearbyint, nextafter, nexttoward,
pow, remainder, remquo, rint, lrint, llrint,
round, lround, llround,
scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
@@ -54,10 +54,14 @@
and for the following complex math functions:
cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
- ccos, ccosh, cexp, clog, cpow, cproj, csin, csinh, csqrt, ctan, ctanh.
+ ccos, ccosh, cexp, cimag, clog, clog10, conj, cpow, cproj, creal,
+ csin, csinh, csqrt, ctan, ctanh.
- At the moment the following functions aren't tested:
- drem, nan
+ At the moment the following functions and macros aren't tested:
+ drem (alias for remainder),
+ lgamma_r,
+ nan,
+ pow10 (alias for exp10).
Parameter handling is primitive in the moment:
--verbose=[0..3] for different levels of output:
@@ -83,8 +87,9 @@
aren't checked at the moment.
NaN values: There exist signalling and quiet NaNs. This implementation
- only uses quiet NaN as parameter but does not differenciate
- between the two kinds of NaNs as result.
+ only uses quiet NaN as parameter but does not differentiate
+ between the two kinds of NaNs as result. Where the sign of a NaN is
+ significant, this is not tested.
Inline functions: Inlining functions should give an improvement in
speed - but not in precission. The inlined functions return
@@ -215,6 +220,7 @@ static int ignore_max_ulp; /* Should we ignore max_ulp? */
static FLOAT minus_zero, plus_zero;
static FLOAT plus_infty, minus_infty, nan_value, max_value, min_value;
+static FLOAT min_subnorm_value;
static FLOAT max_error, real_max_error, imag_max_error;
@@ -2503,6 +2509,66 @@ clog_test (void)
TEST_c_c (clog, 0x1.00000000000000123456789abcp0L, 0x1.23456789p-1000L, 9.868649107778739752403260515979017248596e-19L, 1.061846605795612822522063052130030717368e-301L);
#endif
+ TEST_c_c (clog, 0x0.ffffffp0L, 0x0.ffffffp-100L, -5.960464655174753498633255797994360530379e-8L, 7.888609052210118054117285652827862296732e-31L);
+#ifndef TEST_FLOAT
+ TEST_c_c (clog, 0x0.fffffffffffff8p0L, 0x0.fffffffffffff8p-1000L, -1.110223024625156602053389888482372171810e-16L, 9.332636185032188789900895447238171696171e-302L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MIN_EXP <= -16381
+ TEST_c_c (clog, 0x0.ffffffffffffffffp0L, 0x0.ffffffffffffffffp-15000L, -5.421010862427522170184200798202494495630e-20L, 3.548665303440282824232502561095699343814e-4516L);
+#endif
+
+ TEST_c_c (clog, 0x1a6p-10L, 0x3a5p-10L, -1.4305135209763571252847059962654228661815e-06L, 1.1460277178115757370775644871674016684074L);
+ TEST_c_c (clog, 0xf2p-10L, 0x3e3p-10L, 6.1988446308070710970664736815277450078106e-06L, 1.3322126499153926210226335249558203898460L);
+ TEST_c_c (clog, 0x4d4ep-15L, 0x6605p-15L, -1.6298145321400412054744424587143483169412e-08L, 0.9223574537155056772124552172295398141249L);
+ TEST_c_c (clog, 0x2818p-15L, 0x798fp-15L, 1.5366822245016167178749091974664853785194e-08L, 1.2522014929038946066987318471922169174157L);
+ TEST_c_c (clog, 0x9b57bp-20L, 0xcb7b4p-20L, -3.9563019528687610863490232935890272740908e-11L, 0.9187593477446338910857133065497364950682L);
+ TEST_c_c (clog, 0x2731p-20L, 0xfffd0p-20L, 4.4110493034041283943115971658295280288115e-11L, 1.5612279663766352262688735061954290528838L);
+ TEST_c_c (clog, 0x2ede88p-23L, 0x771c3fp-23L, -4.4764192352906350039050902870893173560494e-13L, 1.1959106857549200806818600493552847793381L);
+ TEST_c_c (clog, 0x11682p-23L, 0x7ffed1p-23L, 1.1723955140027907954461000991619077811832e-12L, 1.5622968405332756349813737986164832897108L);
+ TEST_c_c (clog, 0xa1f2c1p-24L, 0xc643aep-24L, -1.0480505352462576151523512837107080269981e-13L, 0.8858771987699967480545613322309315260313L);
+ TEST_c_c (clog, 0x659feap-24L, 0xeaf6f9p-24L, 3.7303493627403868207597214252239749960738e-14L, 1.1625816408046866464773042283673653469061L);
+#ifndef TEST_FLOAT
+ TEST_c_c (clog, 0x4447d7175p-35L, 0x6c445e00ap-35L, -1.4823076576950255933915367361099865652625e-20L, 1.0081311552703893116404606212158840190615L);
+ TEST_c_c (clog, 0x2dd46725bp-35L, 0x7783a1284p-35L, 4.4469229730850767799109418892826021157328e-20L, 1.2046235979300843056806465045930070146351L);
+ TEST_c_c (clog, 0x164c74eea876p-45L, 0x16f393482f77p-45L, -3.0292258760486853327810377824479932031744e-26L, 0.7998237934177411746093524982030330293980L);
+ TEST_c_c (clog, 0xfe961079616p-45L, 0x1bc37e09e6d1p-45L, 5.3718272201930019901317065495843842735179e-26L, 1.0503831592447830576186444373011142397404L);
+ TEST_c_c (clog, 0xa4722f19346cp-51L, 0x7f9631c5e7f07p-51L, -6.2122796286154679676173624516405339768606e-30L, 1.4904138780720095276446375492434049214172L);
+ TEST_c_c (clog, 0x10673dd0f2481p-51L, 0x7ef1d17cefbd2p-51L, 3.2047474274603604594851472963586149973093e-29L, 1.4422922682185099608731642353544207976604L);
+ TEST_c_c (clog, 0x8ecbf810c4ae6p-52L, 0xd479468b09a37p-52L, -9.7375017988218644730510244778042114638107e-30L, 0.9790637929494922564724108399524154766631L);
+ TEST_c_c (clog, 0x5b06b680ea2ccp-52L, 0xef452b965da9fp-52L, 8.3076914081087805757422664530653247447136e-30L, 1.2072712126771536614482822173033535043206L);
+ TEST_c_c (clog, 0x659b70ab7971bp-53L, 0x1f5d111e08abecp-53L, -2.5083311595699359750201056724289010648701e-30L, 1.3710185432462268491534742969536240564640L);
+ TEST_c_c (clog, 0x15cfbd1990d1ffp-53L, 0x176a3973e09a9ap-53L, 1.0168910106364605304135563536838075568606e-30L, 0.8208373755522359859870890246475340086663L);
+ TEST_c_c (clog, 0x1367a310575591p-54L, 0x3cfcc0a0541f60p-54L, 5.0844550531823026520677817684239496041087e-32L, 1.2627468605458094918919206628466016525397L);
+ TEST_c_c (clog, 0x55cb6d0c83af5p-55L, 0x7fe33c0c7c4e90p-55L, -5.2000108498455368032511404449795741611813e-32L, 1.5288921536982513453421343495466824420259L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 64
+ TEST_c_c (clog, 0x298c62cb546588a7p-63L, 0x7911b1dfcc4ecdaep-63L, -1.1931267660846218205882675852805793644095e-36L, 1.2402109774337032400594953899784058127412L);
+ TEST_c_c (clog, 0x4d9c37e2b5cb4533p-63L, 0x65c98be2385a042ep-63L, 6.4064442119814669184296141278612389400075e-37L, 0.9193591364645830864185131402313014890145L);
+ TEST_c_c (clog, 0x602fd5037c4792efp-64L, 0xed3e2086dcca80b8p-64L, -2.3362950222592964220878638677292132852104e-37L, 1.1856121127236268105413184264288408265852L);
+ TEST_c_c (clog, 0x6b10b4f3520217b6p-64L, 0xe8893cbb449253a1p-64L, 2.4244570985709679851855191080208817099132e-37L, 1.1393074519572050614551047548718495655972L);
+ TEST_c_c (clog, 0x81b7efa81fc35ad1p-65L, 0x1ef4b835f1c79d812p-65L, -9.9182335850630508484862145328126979066934e-39L, 1.3146479888794807046338799047003947008804L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 106
+ TEST_c_c (clog, 0x3f96469050f650869c2p-75L, 0x6f16b2c9c8b05988335p-75L, -1.0509738482436128031927971874674370984602e-45L, 1.0509191467640012308402149909370784281448L);
+ TEST_c_c (clog, 0x3157fc1d73233e580c8p-75L, 0x761b52ccd435d7c7f5fp-75L, 1.3487497719126364307640897239165442763573e-43L, 1.1750493008528425228929764149024375035382L);
+ TEST_c_c (clog, 0x155f8afc4c48685bf63610p-85L, 0x17d0cf2652cdbeb1294e19p-85L, -4.7775669192897997174762089350332738583822e-50L, 0.8393953487996880419413728440067635213372L);
+ TEST_c_c (clog, 0x13836d58a13448d750b4b9p-85L, 0x195ca7bc3ab4f9161edbe6p-85L, 2.8398125044729578740243199963484494962411e-50L, 0.9149964976334130461795060758257083099706L);
+ TEST_c_c (clog, 0x1df515eb171a808b9e400266p-95L, 0x7c71eb0cd4688dfe98581c77p-95L, -3.5048022044913950094635368750889659723004e-57L, 1.3345633256521815205858155673950177421079L);
+ TEST_c_c (clog, 0xe33f66c9542ca25cc43c867p-95L, 0x7f35a68ebd3704a43c465864p-95L, 4.1101771307217268747345114262406964584250e-56L, 1.4596065864518742494094402406719567059585L);
+ TEST_c_c (clog, 0x6771f22c64ed551b857c128b4cp-105L, 0x1f570e7a13cc3cf2f44fd793ea1p-105L, -1.4281333889622737316199756373421183559948e-62L, 1.3673546561165378090903506783353927980633L);
+ TEST_c_c (clog, 0x15d8ab6ed05ca514086ac3a1e84p-105L, 0x1761e480aa094c0b10b34b09ce9p-105L, 1.0027319539522347477331743836657426754857e-62L, 0.8193464073721167323313606647411269414759L);
+ TEST_c_c (clog, 0x187190c1a334497bdbde5a95f48p-106L, 0x3b25f08062d0a095c4cfbbc338dp-106L, -1.7471844652198029695350765775994001163767e-63L, 1.1789110097072986038243729592318526094314L);
+ TEST_c_c (clog, 0x6241ef0da53f539f02fad67dabp-106L, 0x3fb46641182f7efd9caa769dac0p-106L, 4.3299788920664682288477984749202524623248e-63L, 1.4746938237585656250866370987773473745867L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 113
+ TEST_c_c (clog, 0x3e1d0a105ac4ebeacd9c6952d34cp-112L, 0xf859b3d1b06d005dcbb5516d5479p-112L, -1.1683999374665377365054966073875064467108e-66L, 1.3257197596350832748781065387304444940172L);
+ TEST_c_c (clog, 0x47017a2e36807acb1e5214b209dep-112L, 0xf5f4a550c9d75e3bb1839d865f0dp-112L, 1.5077923002544367932999503838191154621839e-65L, 1.2897445708311412721399861948957141824914L);
+ TEST_c_c (clog, 0x148f818cb7a9258fca942ade2a0cap-113L, 0x18854a34780b8333ec53310ad7001p-113L, -7.1865869169568789348552370692485515571497e-67L, 0.8730167479365994646287897223471819363668L);
+ TEST_c_c (clog, 0xfd95243681c055c2632286921092p-113L, 0x1bccabcd29ca2152860ec29e34ef7p-113L, 6.6255694866654064502633121109394710807528e-66L, 1.0526409614996288387567810726095850312049L);
+ TEST_c_c (clog, 0xdb85c467ee2aadd5f425fe0f4b8dp-114L, 0x3e83162a0f95f1dcbf97dddf410eap-114L, 4.6017338806965821566734340588575402712716e-67L, 1.3547418904611758959096647942223384691728L);
+ TEST_c_c (clog, 0x1415bcaf2105940d49a636e98ae59p-115L, 0x7e6a150adfcd1b0921d44b31f40f4p-115L, 2.5993421227864195179698176012564317527271e-67L, 1.4132318089683022770487383611430906982461L);
+#endif
+
END (clog, complex);
}
@@ -2663,6 +2729,66 @@ clog10_test (void)
TEST_c_c (clog10, 0x1.00000000000000123456789abcp0L, 0x1.23456789p-1000L, 4.285899851347756186652871946325962330640e-19L, 4.611541215247321502041995872887317363241e-302L);
#endif
+ TEST_c_c (clog10, 0x0.ffffffp0L, 0x0.ffffffp-100L, -2.588596909321764128428416045209904492216e-8L, 3.425979381266895667295625489912064603415e-31L);
+#ifndef TEST_FLOAT
+ TEST_c_c (clog10, 0x0.fffffffffffff8p0L, 0x0.fffffffffffff8p-1000L, -4.821637332766435821255375046554377090472e-17L, 4.053112396770095089737411317782466262176e-302L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MIN_EXP <= -16381
+ TEST_c_c (clog10, 0x0.ffffffffffffffffp0L, 0x0.ffffffffffffffffp-15000L, -2.354315103889861110220423157644627849164e-20L, 1.541165759405643564697852372112893034397e-4516L);
+#endif
+
+ TEST_c_c (clog10, 0x1a6p-10L, 0x3a5p-10L, -6.2126412844802358329771948751248003038444e-07L, 0.4977135139537443711784513409096950995985L);
+ TEST_c_c (clog10, 0xf2p-10L, 0x3e3p-10L, 2.6921240173351112953324592659528481616879e-06L, 0.5785726025799636431142862788413361783862L);
+ TEST_c_c (clog10, 0x4d4ep-15L, 0x6605p-15L, -7.0781945783414996953799915941870192015212e-09L, 0.4005747524909781155537088181659175147564L);
+ TEST_c_c (clog10, 0x2818p-15L, 0x798fp-15L, 6.6737261053986614395049481326819059203910e-09L, 0.5438241985991753781478398141908629586460L);
+ TEST_c_c (clog10, 0x9b57bp-20L, 0xcb7b4p-20L, -1.7182001068739620267773842120965071561416e-11L, 0.3990121149225253562859800593935899629087L);
+ TEST_c_c (clog10, 0x2731p-20L, 0xfffd0p-20L, 1.9156943718715958194239364991329064049438e-11L, 0.6780326907904082601285090019969008967595L);
+ TEST_c_c (clog10, 0x2ede88p-23L, 0x771c3fp-23L, -1.9440841725722970687903291200493082253766e-13L, 0.5193774116724956222518530053006822210323L);
+ TEST_c_c (clog10, 0x11682p-23L, 0x7ffed1p-23L, 5.0916490233953865181284669870035717560498e-13L, 0.6784968969384861816694467029319146542069L);
+ TEST_c_c (clog10, 0xa1f2c1p-24L, 0xc643aep-24L, -4.5516256421319921959681423447271490869664e-14L, 0.3847315790697197749315054516562206543710L);
+ TEST_c_c (clog10, 0x659feap-24L, 0xeaf6f9p-24L, 1.6200701438094619117335617123525612051457e-14L, 0.5049027913635038013499728086604870749732L);
+#ifndef TEST_FLOAT
+ TEST_c_c (clog10, 0x4447d7175p-35L, 0x6c445e00ap-35L, -6.4375803621988389731799033530075237868110e-21L, 0.4378257977686804492768642780897650927167L);
+ TEST_c_c (clog10, 0x2dd46725bp-35L, 0x7783a1284p-35L, 1.9312741086596516918394613098872836703188e-20L, 0.5231613813514771042838490538484014771862L);
+ TEST_c_c (clog10, 0x164c74eea876p-45L, 0x16f393482f77p-45L, -1.3155760824064879362415202279780039150764e-26L, 0.3473590599762514228227328130640352044313L);
+ TEST_c_c (clog10, 0xfe961079616p-45L, 0x1bc37e09e6d1p-45L, 2.3329549194675052736016290082882121135546e-26L, 0.4561756099441139182878993697611751382976L);
+ TEST_c_c (clog10, 0xa4722f19346cp-51L, 0x7f9631c5e7f07p-51L, -2.6979587627476803379953050733225113494503e-30L, 0.6472785229986997177606324374555347813105L);
+ TEST_c_c (clog10, 0x10673dd0f2481p-51L, 0x7ef1d17cefbd2p-51L, 1.3918041236396763648388478552321724382899e-29L, 0.6263795733790237053262025311642907438291L);
+ TEST_c_c (clog10, 0x8ecbf810c4ae6p-52L, 0xd479468b09a37p-52L, -4.2289432987513243393180377141513840878196e-30L, 0.4252020027092323591068799049905597805296L);
+ TEST_c_c (clog10, 0x5b06b680ea2ccp-52L, 0xef452b965da9fp-52L, 3.6079845358966994996207055940336690133424e-30L, 0.5243112258263349992771652393178033846555L);
+ TEST_c_c (clog10, 0x659b70ab7971bp-53L, 0x1f5d111e08abecp-53L, -1.0893543813872082317104059174982092534059e-30L, 0.5954257879188711495921161433751775633232L);
+ TEST_c_c (clog10, 0x15cfbd1990d1ffp-53L, 0x176a3973e09a9ap-53L, 4.4163015461643576961232672330852798804976e-31L, 0.3564851427422832755956993418877523303529L);
+ TEST_c_c (clog10, 0x1367a310575591p-54L, 0x3cfcc0a0541f60p-54L, 2.2081507730821788480616336165447731164865e-32L, 0.5484039935757001196548030312819898864760L);
+ TEST_c_c (clog10, 0x55cb6d0c83af5p-55L, 0x7fe33c0c7c4e90p-55L, -2.2583360179249556400630343805573865814771e-32L, 0.6639894257763289307423302343317622430835L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 64
+ TEST_c_c (clog10, 0x298c62cb546588a7p-63L, 0x7911b1dfcc4ecdaep-63L, -5.1816837072162316773907242302011632570857e-37L, 0.5386167838952956925896424154370364458140L);
+ TEST_c_c (clog10, 0x4d9c37e2b5cb4533p-63L, 0x65c98be2385a042ep-63L, 2.7822833698845776001753149807484078521508e-37L, 0.3992725998539071066769046272515417679815L);
+ TEST_c_c (clog10, 0x602fd5037c4792efp-64L, 0xed3e2086dcca80b8p-64L, -1.0146400362652473358437501879334790111898e-37L, 0.5149047982335273098246594109614460842099L);
+ TEST_c_c (clog10, 0x6b10b4f3520217b6p-64L, 0xe8893cbb449253a1p-64L, 1.0529283395205396881397407610630442563938e-37L, 0.4947949395762683446121140513971996916447L);
+ TEST_c_c (clog10, 0x81b7efa81fc35ad1p-65L, 0x1ef4b835f1c79d812p-65L, -4.3074341162203896332989394770760901408798e-39L, 0.5709443672155660428417571212549720987784L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 106
+ TEST_c_c (clog10, 0x3f96469050f650869c2p-75L, 0x6f16b2c9c8b05988335p-75L, -4.5643214291682663316715446865040356750881e-46L, 0.4564083863660793840592614609053162690362L);
+ TEST_c_c (clog10, 0x3157fc1d73233e580c8p-75L, 0x761b52ccd435d7c7f5fp-75L, 5.8575458340992751256451490143468457830297e-44L, 0.5103174273246635294300470585396890237265L);
+ TEST_c_c (clog10, 0x155f8afc4c48685bf63610p-85L, 0x17d0cf2652cdbeb1294e19p-85L, -2.0748709499710785084693619097712106753591e-50L, 0.3645447681189598740620098186365764884771L);
+ TEST_c_c (clog10, 0x13836d58a13448d750b4b9p-85L, 0x195ca7bc3ab4f9161edbe6p-85L, 1.2333149003324592532859843519619084433953e-50L, 0.3973779298829931059309198145608711073016L);
+ TEST_c_c (clog10, 0x1df515eb171a808b9e400266p-95L, 0x7c71eb0cd4688dfe98581c77p-95L, -1.5221162575729652613635150540947625639689e-57L, 0.5795934880811949230121092882659698986043L);
+ TEST_c_c (clog10, 0xe33f66c9542ca25cc43c867p-95L, 0x7f35a68ebd3704a43c465864p-95L, 1.7850272475173865337808494725293124613817e-56L, 0.6338990862456906754888183278564382516852L);
+ TEST_c_c (clog10, 0x6771f22c64ed551b857c128b4cp-105L, 0x1f570e7a13cc3cf2f44fd793ea1p-105L, -6.2023045024810589256360494043570293518879e-63L, 0.5938345819561308555003145899438513900776L);
+ TEST_c_c (clog10, 0x15d8ab6ed05ca514086ac3a1e84p-105L, 0x1761e480aa094c0b10b34b09ce9p-105L, 4.3548095442952115860848857519953610343042e-63L, 0.3558376234889641500775150477035448866763L);
+ TEST_c_c (clog10, 0x187190c1a334497bdbde5a95f48p-106L, 0x3b25f08062d0a095c4cfbbc338dp-106L, -7.5879257211204444302994221436282805900756e-64L, 0.5119945461708707332160859198685423099187L);
+ TEST_c_c (clog10, 0x6241ef0da53f539f02fad67dabp-106L, 0x3fb46641182f7efd9caa769dac0p-106L, 1.8804859395820231849002915747252695375405e-63L, 0.6404513901551516189871978418046651877394L);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 113
+ TEST_c_c (clog10, 0x3e1d0a105ac4ebeacd9c6952d34cp-112L, 0xf859b3d1b06d005dcbb5516d5479p-112L, -5.0742964549782184008668435276046798273476e-67L, 0.5757527761596220360985719127090110408283L);
+ TEST_c_c (clog10, 0x47017a2e36807acb1e5214b209dep-112L, 0xf5f4a550c9d75e3bb1839d865f0dp-112L, 6.5482587585671294601662599808612773010057e-66L, 0.5601289501766423782280643144987875760229L);
+ TEST_c_c (clog10, 0x148f818cb7a9258fca942ade2a0cap-113L, 0x18854a34780b8333ec53310ad7001p-113L, -3.1210950417524756037077807411854181477733e-67L, 0.3791463562379872585396164879981280044658L);
+ TEST_c_c (clog10, 0xfd95243681c055c2632286921092p-113L, 0x1bccabcd29ca2152860ec29e34ef7p-113L, 2.8774482675253468630312378575186855052697e-66L, 0.4571561610046221605554903008571429975493L);
+ TEST_c_c (clog10, 0xdb85c467ee2aadd5f425fe0f4b8dp-114L, 0x3e83162a0f95f1dcbf97dddf410eap-114L, 1.9985076315737626043096596036300177494613e-67L, 0.5883569274304683249184005177865521205198L);
+ TEST_c_c (clog10, 0x1415bcaf2105940d49a636e98ae59p-115L, 0x7e6a150adfcd1b0921d44b31f40f4p-115L, 1.1288799405048268615023706955013387413519e-67L, 0.6137587762850841972073301550420510507903L);
+#endif
+
END (clog10, complex);
}
@@ -4299,6 +4425,23 @@ fdim_test (void)
static void
+finite_test (void)
+{
+ START (finite);
+
+ TEST_f_b (finite, 0, 1);
+ TEST_f_b (finite, minus_zero, 1);
+ TEST_f_b (finite, 10, 1);
+ TEST_f_b (finite, min_subnorm_value, 1);
+ TEST_f_b (finite, plus_infty, 0);
+ TEST_f_b (finite, minus_infty, 0);
+ TEST_f_b (finite, nan_value, 0);
+
+ END (finite);
+}
+
+
+static void
floor_test (void)
{
START (floor);
@@ -4439,6 +4582,45 @@ fma_test (void)
TEST_fff_f (fma, minus_infty, minus_infty, plus_infty, plus_infty);
TEST_fff_f (fma, plus_infty, minus_infty, minus_infty, minus_infty);
+ TEST_fff_f (fma, plus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, minus_zero, plus_zero);
+
+ TEST_fff_f (fma, 1.0, 1.0, -1.0, plus_zero);
+ TEST_fff_f (fma, 1.0, -1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, 1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, -1.0, -1.0, plus_zero);
+
+ TEST_fff_f (fma, min_value, min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+
#if defined (TEST_FLOAT) && FLT_MANT_DIG == 24
TEST_fff_f (fma, 0x1.7ff8p+13, 0x1.000002p+0, 0x1.ffffp-24, 0x1.7ff802p+13);
TEST_fff_f (fma, 0x1.fffp+0, 0x1.00001p+0, -0x1.fffp+0, 0x1.fffp-20);
@@ -4501,6 +4683,174 @@ fma_test (void)
static void
+fma_test_towardzero (void)
+{
+ int save_round_mode;
+ START (fma_towardzero);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_TOWARDZERO))
+ {
+ TEST_fff_f (fma, plus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, minus_zero, plus_zero);
+
+ TEST_fff_f (fma, 1.0, 1.0, -1.0, plus_zero);
+ TEST_fff_f (fma, 1.0, -1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, 1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, -1.0, -1.0, plus_zero);
+
+ TEST_fff_f (fma, min_value, min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ }
+
+ fesetround (save_round_mode);
+
+ END (fma_towardzero);
+}
+
+
+static void
+fma_test_downward (void)
+{
+ int save_round_mode;
+ START (fma_downward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_DOWNWARD))
+ {
+ TEST_fff_f (fma, plus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, plus_zero, minus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, plus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, plus_zero, minus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, plus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, plus_zero, minus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, plus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, minus_zero, minus_zero);
+
+ TEST_fff_f (fma, 1.0, 1.0, -1.0, minus_zero);
+ TEST_fff_f (fma, 1.0, -1.0, 1.0, minus_zero);
+ TEST_fff_f (fma, -1.0, 1.0, 1.0, minus_zero);
+ TEST_fff_f (fma, -1.0, -1.0, -1.0, minus_zero);
+
+ TEST_fff_f (fma, min_value, min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, plus_zero, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, minus_zero, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, plus_zero, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, minus_zero, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, plus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, minus_zero, plus_zero, UNDERFLOW_EXCEPTION);
+ }
+
+ fesetround (save_round_mode);
+
+ END (fma_downward);
+}
+
+
+static void
+fma_test_upward (void)
+{
+ int save_round_mode;
+ START (fma_upward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_UPWARD))
+ {
+ TEST_fff_f (fma, plus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, plus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, 1.0, minus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, plus_zero, minus_zero, minus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, plus_zero, plus_zero);
+ TEST_fff_f (fma, -1.0, minus_zero, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, 1.0, minus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, plus_zero, -1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, 1.0, minus_zero, minus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, plus_zero, plus_zero);
+ TEST_fff_f (fma, minus_zero, -1.0, minus_zero, plus_zero);
+
+ TEST_fff_f (fma, 1.0, 1.0, -1.0, plus_zero);
+ TEST_fff_f (fma, 1.0, -1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, 1.0, 1.0, plus_zero);
+ TEST_fff_f (fma, -1.0, -1.0, -1.0, plus_zero);
+
+ TEST_fff_f (fma, min_value, min_value, plus_zero, min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, min_value, minus_zero, min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, min_value, -min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, plus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, min_value, minus_zero, minus_zero, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, plus_zero, min_subnorm_value, UNDERFLOW_EXCEPTION);
+ TEST_fff_f (fma, -min_value, -min_value, minus_zero, min_subnorm_value, UNDERFLOW_EXCEPTION);
+ }
+
+ fesetround (save_round_mode);
+
+ END (fma_upward);
+}
+
+
+static void
fmax_test (void)
{
START (fmax);
@@ -4642,6 +4992,7 @@ fpclassify_test (void)
TEST_f_i (fpclassify, plus_zero, FP_ZERO);
TEST_f_i (fpclassify, minus_zero, FP_ZERO);
TEST_f_i (fpclassify, 1000, FP_NORMAL);
+ TEST_f_i (fpclassify, min_subnorm_value, FP_SUBNORMAL);
END (fpclassify);
}
@@ -4791,6 +5142,7 @@ isfinite_test (void)
TEST_f_b (isfinite, 0, 1);
TEST_f_b (isfinite, minus_zero, 1);
TEST_f_b (isfinite, 10, 1);
+ TEST_f_b (isfinite, min_subnorm_value, 1);
TEST_f_b (isfinite, plus_infty, 0);
TEST_f_b (isfinite, minus_infty, 0);
TEST_f_b (isfinite, nan_value, 0);
@@ -4799,6 +5151,163 @@ isfinite_test (void)
}
static void
+isgreater_test (void)
+{
+ START (isgreater);
+
+ TEST_ff_i (isgreater, minus_zero, minus_zero, 0);
+ TEST_ff_i (isgreater, minus_zero, plus_zero, 0);
+ TEST_ff_i (isgreater, minus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isgreater, minus_zero, nan_value, 0);
+ TEST_ff_i (isgreater, plus_zero, minus_zero, 0);
+ TEST_ff_i (isgreater, plus_zero, plus_zero, 0);
+ TEST_ff_i (isgreater, plus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isgreater, plus_zero, nan_value, 0);
+ TEST_ff_i (isgreater, (FLOAT) 1, minus_zero, 1);
+ TEST_ff_i (isgreater, (FLOAT) 1, plus_zero, 1);
+ TEST_ff_i (isgreater, (FLOAT) 1, (FLOAT) 1, 0);
+ TEST_ff_i (isgreater, (FLOAT) 1, nan_value, 0);
+ TEST_ff_i (isgreater, nan_value, minus_zero, 0);
+ TEST_ff_i (isgreater, nan_value, plus_zero, 0);
+ TEST_ff_i (isgreater, nan_value, (FLOAT) 1, 0);
+ TEST_ff_i (isgreater, nan_value, nan_value, 0);
+
+ END (isgreater);
+}
+
+static void
+isgreaterequal_test (void)
+{
+ START (isgreaterequal);
+
+ TEST_ff_i (isgreaterequal, minus_zero, minus_zero, 1);
+ TEST_ff_i (isgreaterequal, minus_zero, plus_zero, 1);
+ TEST_ff_i (isgreaterequal, minus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isgreaterequal, minus_zero, nan_value, 0);
+ TEST_ff_i (isgreaterequal, plus_zero, minus_zero, 1);
+ TEST_ff_i (isgreaterequal, plus_zero, plus_zero, 1);
+ TEST_ff_i (isgreaterequal, plus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isgreaterequal, plus_zero, nan_value, 0);
+ TEST_ff_i (isgreaterequal, (FLOAT) 1, minus_zero, 1);
+ TEST_ff_i (isgreaterequal, (FLOAT) 1, plus_zero, 1);
+ TEST_ff_i (isgreaterequal, (FLOAT) 1, (FLOAT) 1, 1);
+ TEST_ff_i (isgreaterequal, (FLOAT) 1, nan_value, 0);
+ TEST_ff_i (isgreaterequal, nan_value, minus_zero, 0);
+ TEST_ff_i (isgreaterequal, nan_value, plus_zero, 0);
+ TEST_ff_i (isgreaterequal, nan_value, (FLOAT) 1, 0);
+ TEST_ff_i (isgreaterequal, nan_value, nan_value, 0);
+
+ END (isgreaterequal);
+}
+
+static void
+isinf_test (void)
+{
+ START (isinf);
+
+ TEST_f_b (isinf, 0, 0);
+ TEST_f_b (isinf, minus_zero, 0);
+ TEST_f_b (isinf, 10, 0);
+ TEST_f_b (isinf, min_subnorm_value, 0);
+ TEST_f_b (isinf, plus_infty, 1);
+ TEST_f_b (isinf, minus_infty, 1);
+ TEST_f_b (isinf, nan_value, 0);
+
+ END (isinf);
+}
+
+static void
+isless_test (void)
+{
+ START (isless);
+
+ TEST_ff_i (isless, minus_zero, minus_zero, 0);
+ TEST_ff_i (isless, minus_zero, plus_zero, 0);
+ TEST_ff_i (isless, minus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (isless, minus_zero, nan_value, 0);
+ TEST_ff_i (isless, plus_zero, minus_zero, 0);
+ TEST_ff_i (isless, plus_zero, plus_zero, 0);
+ TEST_ff_i (isless, plus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (isless, plus_zero, nan_value, 0);
+ TEST_ff_i (isless, (FLOAT) 1, minus_zero, 0);
+ TEST_ff_i (isless, (FLOAT) 1, plus_zero, 0);
+ TEST_ff_i (isless, (FLOAT) 1, (FLOAT) 1, 0);
+ TEST_ff_i (isless, (FLOAT) 1, nan_value, 0);
+ TEST_ff_i (isless, nan_value, minus_zero, 0);
+ TEST_ff_i (isless, nan_value, plus_zero, 0);
+ TEST_ff_i (isless, nan_value, (FLOAT) 1, 0);
+ TEST_ff_i (isless, nan_value, nan_value, 0);
+
+ END (isless);
+}
+
+static void
+islessequal_test (void)
+{
+ START (islessequal);
+
+ TEST_ff_i (islessequal, minus_zero, minus_zero, 1);
+ TEST_ff_i (islessequal, minus_zero, plus_zero, 1);
+ TEST_ff_i (islessequal, minus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (islessequal, minus_zero, nan_value, 0);
+ TEST_ff_i (islessequal, plus_zero, minus_zero, 1);
+ TEST_ff_i (islessequal, plus_zero, plus_zero, 1);
+ TEST_ff_i (islessequal, plus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (islessequal, plus_zero, nan_value, 0);
+ TEST_ff_i (islessequal, (FLOAT) 1, minus_zero, 0);
+ TEST_ff_i (islessequal, (FLOAT) 1, plus_zero, 0);
+ TEST_ff_i (islessequal, (FLOAT) 1, (FLOAT) 1, 1);
+ TEST_ff_i (islessequal, (FLOAT) 1, nan_value, 0);
+ TEST_ff_i (islessequal, nan_value, minus_zero, 0);
+ TEST_ff_i (islessequal, nan_value, plus_zero, 0);
+ TEST_ff_i (islessequal, nan_value, (FLOAT) 1, 0);
+ TEST_ff_i (islessequal, nan_value, nan_value, 0);
+
+ END (islessequal);
+}
+
+static void
+islessgreater_test (void)
+{
+ START (islessgreater);
+
+ TEST_ff_i (islessgreater, minus_zero, minus_zero, 0);
+ TEST_ff_i (islessgreater, minus_zero, plus_zero, 0);
+ TEST_ff_i (islessgreater, minus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (islessgreater, minus_zero, nan_value, 0);
+ TEST_ff_i (islessgreater, plus_zero, minus_zero, 0);
+ TEST_ff_i (islessgreater, plus_zero, plus_zero, 0);
+ TEST_ff_i (islessgreater, plus_zero, (FLOAT) 1, 1);
+ TEST_ff_i (islessgreater, plus_zero, nan_value, 0);
+ TEST_ff_i (islessgreater, (FLOAT) 1, minus_zero, 1);
+ TEST_ff_i (islessgreater, (FLOAT) 1, plus_zero, 1);
+ TEST_ff_i (islessgreater, (FLOAT) 1, (FLOAT) 1, 0);
+ TEST_ff_i (islessgreater, (FLOAT) 1, nan_value, 0);
+ TEST_ff_i (islessgreater, nan_value, minus_zero, 0);
+ TEST_ff_i (islessgreater, nan_value, plus_zero, 0);
+ TEST_ff_i (islessgreater, nan_value, (FLOAT) 1, 0);
+ TEST_ff_i (islessgreater, nan_value, nan_value, 0);
+
+ END (islessgreater);
+}
+
+static void
+isnan_test (void)
+{
+ START (isnan);
+
+ TEST_f_b (isnan, 0, 0);
+ TEST_f_b (isnan, minus_zero, 0);
+ TEST_f_b (isnan, 10, 0);
+ TEST_f_b (isnan, min_subnorm_value, 0);
+ TEST_f_b (isnan, plus_infty, 0);
+ TEST_f_b (isnan, minus_infty, 0);
+ TEST_f_b (isnan, nan_value, 1);
+
+ END (isnan);
+}
+
+static void
isnormal_test (void)
{
START (isnormal);
@@ -4806,6 +5315,7 @@ isnormal_test (void)
TEST_f_b (isnormal, 0, 0);
TEST_f_b (isnormal, minus_zero, 0);
TEST_f_b (isnormal, 10, 1);
+ TEST_f_b (isnormal, min_subnorm_value, 0);
TEST_f_b (isnormal, plus_infty, 0);
TEST_f_b (isnormal, minus_infty, 0);
TEST_f_b (isnormal, nan_value, 0);
@@ -4814,6 +5324,31 @@ isnormal_test (void)
}
static void
+isunordered_test (void)
+{
+ START (isunordered);
+
+ TEST_ff_i (isunordered, minus_zero, minus_zero, 0);
+ TEST_ff_i (isunordered, minus_zero, plus_zero, 0);
+ TEST_ff_i (isunordered, minus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isunordered, minus_zero, nan_value, 1);
+ TEST_ff_i (isunordered, plus_zero, minus_zero, 0);
+ TEST_ff_i (isunordered, plus_zero, plus_zero, 0);
+ TEST_ff_i (isunordered, plus_zero, (FLOAT) 1, 0);
+ TEST_ff_i (isunordered, plus_zero, nan_value, 1);
+ TEST_ff_i (isunordered, (FLOAT) 1, minus_zero, 0);
+ TEST_ff_i (isunordered, (FLOAT) 1, plus_zero, 0);
+ TEST_ff_i (isunordered, (FLOAT) 1, (FLOAT) 1, 0);
+ TEST_ff_i (isunordered, (FLOAT) 1, nan_value, 1);
+ TEST_ff_i (isunordered, nan_value, minus_zero, 1);
+ TEST_ff_i (isunordered, nan_value, plus_zero, 1);
+ TEST_ff_i (isunordered, nan_value, (FLOAT) 1, 1);
+ TEST_ff_i (isunordered, nan_value, nan_value, 1);
+
+ END (isunordered);
+}
+
+static void
j0_test (void)
{
FLOAT s, c;
@@ -9153,6 +9688,12 @@ initialize (void)
LDBL_MAX, DBL_MAX, FLT_MAX);
min_value = CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN,
LDBL_MIN, DBL_MIN, FLT_MIN);
+ min_subnorm_value = CHOOSE (__LDBL_DENORM_MIN__,
+ __DBL_DENORM_MIN__,
+ __FLT_DENORM_MIN__,
+ __LDBL_DENORM_MIN__,
+ __DBL_DENORM_MIN__,
+ __FLT_DENORM_MIN__);
(void) &plus_zero;
(void) &nan_value;
@@ -9161,6 +9702,7 @@ initialize (void)
(void) &minus_infty;
(void) &max_value;
(void) &min_value;
+ (void) &min_subnorm_value;
/* Clear all exceptions. From now on we must not get random exceptions. */
feclearexcept (FE_ALL_EXCEPT);
@@ -9298,8 +9840,11 @@ main (int argc, char **argv)
/* Keep the tests a wee bit ordered (according to ISO C99). */
/* Classification macros: */
+ finite_test ();
fpclassify_test ();
isfinite_test ();
+ isinf_test ();
+ isnan_test ();
isnormal_test ();
signbit_test ();
@@ -9432,6 +9977,17 @@ main (int argc, char **argv)
/* Multiply and add: */
fma_test ();
+ fma_test_towardzero ();
+ fma_test_downward ();
+ fma_test_upward ();
+
+ /* Comparison macros: */
+ isgreater_test ();
+ isgreaterequal_test ();
+ isless_test ();
+ islessequal_test ();
+ islessgreater_test ();
+ isunordered_test ();
/* Complex functions: */
cabs_test ();
diff --git a/libc/math/s_ccosh.c b/libc/math/s_ccosh.c
index 44c994446..91477ee2d 100644
--- a/libc/math/s_ccosh.c
+++ b/libc/math/s_ccosh.c
@@ -39,7 +39,15 @@ __ccosh (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabs (__real__ x) > t)
{
@@ -92,7 +100,15 @@ __ccosh (__complex__ double x)
/* Imaginary part is finite. */
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = (__copysign (HUGE_VAL, sinix)
diff --git a/libc/math/s_ccoshf.c b/libc/math/s_ccoshf.c
index d6f811049..9ca57b25b 100644
--- a/libc/math/s_ccoshf.c
+++ b/libc/math/s_ccoshf.c
@@ -39,7 +39,15 @@ __ccoshf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
if (fabsf (__real__ x) > t)
{
@@ -92,7 +100,15 @@ __ccoshf (__complex__ float x)
/* Imaginary part is finite. */
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = (__copysignf (HUGE_VALF, sinix)
diff --git a/libc/math/s_ccoshl.c b/libc/math/s_ccoshl.c
index 77a9ae386..1d561b4e3 100644
--- a/libc/math/s_ccoshl.c
+++ b/libc/math/s_ccoshl.c
@@ -39,7 +39,15 @@ __ccoshl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabsl (__real__ x) > t)
{
@@ -92,7 +100,15 @@ __ccoshl (__complex__ long double x)
/* Imaginary part is finite. */
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = (__copysignl (HUGE_VALL, sinix)
diff --git a/libc/math/s_cexp.c b/libc/math/s_cexp.c
index 1d7a5a2c4..d0a95ba79 100644
--- a/libc/math/s_cexp.c
+++ b/libc/math/s_cexp.c
@@ -39,7 +39,15 @@ __cexp (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (__real__ x > t)
{
@@ -95,7 +103,15 @@ __cexp (__complex__ double x)
{
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysign (value, cosix);
__imag__ retval = __copysign (value, sinix);
diff --git a/libc/math/s_cexpf.c b/libc/math/s_cexpf.c
index 4aa976581..41fcea51d 100644
--- a/libc/math/s_cexpf.c
+++ b/libc/math/s_cexpf.c
@@ -39,7 +39,15 @@ __cexpf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
if (__real__ x > t)
{
@@ -95,7 +103,15 @@ __cexpf (__complex__ float x)
{
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
__real__ retval = __copysignf (value, cosix);
__imag__ retval = __copysignf (value, sinix);
diff --git a/libc/math/s_cexpl.c b/libc/math/s_cexpl.c
index 256824924..d67cc5e5e 100644
--- a/libc/math/s_cexpl.c
+++ b/libc/math/s_cexpl.c
@@ -39,7 +39,15 @@ __cexpl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (__real__ x > t)
{
@@ -95,7 +103,15 @@ __cexpl (__complex__ long double x)
{
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysignl (value, cosix);
__imag__ retval = __copysignl (value, sinix);
diff --git a/libc/math/s_clog.c b/libc/math/s_clog.c
index 259306600..79b1f375d 100644
--- a/libc/math/s_clog.c
+++ b/libc/math/s_clog.c
@@ -85,6 +85,19 @@ __clog (__complex__ double x)
d2m1 += absy * absy;
__real__ result = __log1p (d2m1) / 2.0;
}
+ else if (absx < 1.0
+ && absx >= 0.75
+ && absy < DBL_EPSILON / 2.0
+ && scale == 0)
+ {
+ double d2m1 = (absx - 1.0) * (absx + 1.0);
+ __real__ result = __log1p (d2m1) / 2.0;
+ }
+ else if (absx < 1.0 && (absx >= 0.75 || absy >= 0.5) && scale == 0)
+ {
+ double d2m1 = __x2y2m1 (absx, absy);
+ __real__ result = __log1p (d2m1) / 2.0;
+ }
else
{
double d = __ieee754_hypot (absx, absy);
diff --git a/libc/math/s_clog10.c b/libc/math/s_clog10.c
index ef997ee76..4ccb5bcaa 100644
--- a/libc/math/s_clog10.c
+++ b/libc/math/s_clog10.c
@@ -88,6 +88,19 @@ __clog10 (__complex__ double x)
d2m1 += absy * absy;
__real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
}
+ else if (absx < 1.0
+ && absx >= 0.75
+ && absy < DBL_EPSILON / 2.0
+ && scale == 0)
+ {
+ double d2m1 = (absx - 1.0) * (absx + 1.0);
+ __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
+ }
+ else if (absx < 1.0 && (absx >= 0.75 || absy >= 0.5) && scale == 0)
+ {
+ double d2m1 = __x2y2m1 (absx, absy);
+ __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
+ }
else
{
double d = __ieee754_hypot (absx, absy);
diff --git a/libc/math/s_clog10f.c b/libc/math/s_clog10f.c
index c61e8af8c..1789f1aed 100644
--- a/libc/math/s_clog10f.c
+++ b/libc/math/s_clog10f.c
@@ -90,6 +90,19 @@ __clog10f (__complex__ float x)
d2m1 += absy * absy;
__real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
}
+ else if (absx < 1.0f
+ && absx >= 0.75f
+ && absy < FLT_EPSILON / 2.0f
+ && scale == 0)
+ {
+ float d2m1 = (absx - 1.0f) * (absx + 1.0f);
+ __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
+ }
+ else if (absx < 1.0f && (absx >= 0.75f || absy >= 0.5f) && scale == 0)
+ {
+ float d2m1 = __x2y2m1f (absx, absy);
+ __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
+ }
else
{
float d = __ieee754_hypotf (absx, absy);
diff --git a/libc/math/s_clog10l.c b/libc/math/s_clog10l.c
index d50f61657..958f74abd 100644
--- a/libc/math/s_clog10l.c
+++ b/libc/math/s_clog10l.c
@@ -89,6 +89,19 @@ __clog10l (__complex__ long double x)
d2m1 += absy * absy;
__real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
}
+ else if (absx < 1.0L
+ && absx >= 0.75L
+ && absy < LDBL_EPSILON / 2.0L
+ && scale == 0)
+ {
+ long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
+ __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
+ }
+ else if (absx < 1.0L && (absx >= 0.75L || absy >= 0.5L) && scale == 0)
+ {
+ long double d2m1 = __x2y2m1l (absx, absy);
+ __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
+ }
else
{
long double d = __ieee754_hypotl (absx, absy);
diff --git a/libc/math/s_clogf.c b/libc/math/s_clogf.c
index 92f782c47..2b9038b41 100644
--- a/libc/math/s_clogf.c
+++ b/libc/math/s_clogf.c
@@ -85,6 +85,19 @@ __clogf (__complex__ float x)
d2m1 += absy * absy;
__real__ result = __log1pf (d2m1) / 2.0f;
}
+ else if (absx < 1.0f
+ && absx >= 0.75f
+ && absy < FLT_EPSILON / 2.0f
+ && scale == 0)
+ {
+ float d2m1 = (absx - 1.0f) * (absx + 1.0f);
+ __real__ result = __log1pf (d2m1) / 2.0f;
+ }
+ else if (absx < 1.0f && (absx >= 0.75f || absy >= 0.5f) && scale == 0)
+ {
+ float d2m1 = __x2y2m1f (absx, absy);
+ __real__ result = __log1pf (d2m1) / 2.0f;
+ }
else
{
float d = __ieee754_hypotf (absx, absy);
diff --git a/libc/math/s_clogl.c b/libc/math/s_clogl.c
index eaba572ce..af3ed9971 100644
--- a/libc/math/s_clogl.c
+++ b/libc/math/s_clogl.c
@@ -85,6 +85,19 @@ __clogl (__complex__ long double x)
d2m1 += absy * absy;
__real__ result = __log1pl (d2m1) / 2.0L;
}
+ else if (absx < 1.0L
+ && absx >= 0.75L
+ && absy < LDBL_EPSILON / 2.0L
+ && scale == 0)
+ {
+ long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
+ __real__ result = __log1pl (d2m1) / 2.0L;
+ }
+ else if (absx < 1.0L && (absx >= 0.75L || absy >= 0.5L) && scale == 0)
+ {
+ long double d2m1 = __x2y2m1l (absx, absy);
+ __real__ result = __log1pl (d2m1) / 2.0L;
+ }
else
{
long double d = __ieee754_hypotl (absx, absy);
diff --git a/libc/math/s_csin.c b/libc/math/s_csin.c
index 602c14e53..725989c9c 100644
--- a/libc/math/s_csin.c
+++ b/libc/math/s_csin.c
@@ -42,7 +42,15 @@ __csin (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
- __sincos (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0;
+ }
if (fabs (__imag__ x) > t)
{
@@ -115,7 +123,15 @@ __csin (__complex__ double x)
/* Real part is finite. */
double sinix, cosix;
- __sincos (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysign (HUGE_VAL, sinix);
__imag__ retval = __copysign (HUGE_VAL, cosix);
diff --git a/libc/math/s_csinf.c b/libc/math/s_csinf.c
index c1d6a4f28..d53f943fa 100644
--- a/libc/math/s_csinf.c
+++ b/libc/math/s_csinf.c
@@ -42,7 +42,15 @@ __csinf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
- __sincosf (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0f;
+ }
if (fabsf (__imag__ x) > t)
{
@@ -115,7 +123,15 @@ __csinf (__complex__ float x)
/* Real part is finite. */
float sinix, cosix;
- __sincosf (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0f;
+ }
__real__ retval = __copysignf (HUGE_VALF, sinix);
__imag__ retval = __copysignf (HUGE_VALF, cosix);
diff --git a/libc/math/s_csinh.c b/libc/math/s_csinh.c
index 56bb25623..20edbd13f 100644
--- a/libc/math/s_csinh.c
+++ b/libc/math/s_csinh.c
@@ -42,7 +42,15 @@ __csinh (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabs (__real__ x) > t)
{
@@ -109,7 +117,15 @@ __csinh (__complex__ double x)
/* Imaginary part is finite. */
double sinix, cosix;
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = __copysign (HUGE_VAL, sinix);
diff --git a/libc/math/s_csinhf.c b/libc/math/s_csinhf.c
index ba85e79b8..4b019a0ed 100644
--- a/libc/math/s_csinhf.c
+++ b/libc/math/s_csinhf.c
@@ -42,7 +42,15 @@ __csinhf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
if (fabsf (__real__ x) > t)
{
@@ -109,7 +117,15 @@ __csinhf (__complex__ float x)
/* Imaginary part is finite. */
float sinix, cosix;
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = __copysignf (HUGE_VALF, sinix);
diff --git a/libc/math/s_csinhl.c b/libc/math/s_csinhl.c
index e482e3a62..d9a928a40 100644
--- a/libc/math/s_csinhl.c
+++ b/libc/math/s_csinhl.c
@@ -42,7 +42,15 @@ __csinhl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabsl (__real__ x) > t)
{
@@ -109,7 +117,15 @@ __csinhl (__complex__ long double x)
/* Imaginary part is finite. */
long double sinix, cosix;
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = __copysignl (HUGE_VALL, sinix);
diff --git a/libc/math/s_csinl.c b/libc/math/s_csinl.c
index ff43256e5..9812bddd5 100644
--- a/libc/math/s_csinl.c
+++ b/libc/math/s_csinl.c
@@ -42,7 +42,15 @@ __csinl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
- __sincosl (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0;
+ }
if (fabsl (__imag__ x) > t)
{
@@ -115,7 +123,15 @@ __csinl (__complex__ long double x)
/* Real part is finite. */
long double sinix, cosix;
- __sincosl (__real__ x, &sinix, &cosix);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__real__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __real__ x;
+ cosix = 1.0;
+ }
__real__ retval = __copysignl (HUGE_VALL, sinix);
__imag__ retval = __copysignl (HUGE_VALL, cosix);
diff --git a/libc/math/s_ctan.c b/libc/math/s_ctan.c
index 89c0fef91..fdba84744 100644
--- a/libc/math/s_ctan.c
+++ b/libc/math/s_ctan.c
@@ -53,11 +53,20 @@ __ctan (__complex__ double x)
double sinrx, cosrx;
double den;
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
+ int rcls = fpclassify (__real__ x);
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
- __sincos (__real__ x, &sinrx, &cosrx);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__real__ x, &sinrx, &cosrx);
+ }
+ else
+ {
+ sinrx = __real__ x;
+ cosrx = 1.0;
+ }
if (fabs (__imag__ x) > t)
{
diff --git a/libc/math/s_ctanf.c b/libc/math/s_ctanf.c
index 2559f83f8..fd2b79788 100644
--- a/libc/math/s_ctanf.c
+++ b/libc/math/s_ctanf.c
@@ -57,7 +57,15 @@ __ctanf (__complex__ float x)
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
- __sincosf (__real__ x, &sinrx, &cosrx);
+ if (__builtin_expect (fpclassify(__real__ x) != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__real__ x, &sinrx, &cosrx);
+ }
+ else
+ {
+ sinrx = __real__ x;
+ cosrx = 1.0f;
+ }
if (fabsf (__imag__ x) > t)
{
diff --git a/libc/math/s_ctanh.c b/libc/math/s_ctanh.c
index d288b7d16..fee191055 100644
--- a/libc/math/s_ctanh.c
+++ b/libc/math/s_ctanh.c
@@ -53,11 +53,20 @@ __ctanh (__complex__ double x)
double sinix, cosix;
double den;
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
+ int icls = fpclassify (__imag__ x);
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
- __sincos (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincos (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabs (__real__ x) > t)
{
diff --git a/libc/math/s_ctanhf.c b/libc/math/s_ctanhf.c
index ca36a83bf..862845f8c 100644
--- a/libc/math/s_ctanhf.c
+++ b/libc/math/s_ctanhf.c
@@ -57,7 +57,15 @@ __ctanhf (__complex__ float x)
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
- __sincosf (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (fpclassify(__imag__ x) != FP_SUBNORMAL, 1))
+ {
+ __sincosf (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0f;
+ }
if (fabsf (__real__ x) > t)
{
diff --git a/libc/math/s_ctanhl.c b/libc/math/s_ctanhl.c
index dbf161270..c4fc1d3d0 100644
--- a/libc/math/s_ctanhl.c
+++ b/libc/math/s_ctanhl.c
@@ -53,11 +53,20 @@ __ctanhl (__complex__ long double x)
long double sinix, cosix;
long double den;
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
+ int icls = fpclassify (__imag__ x);
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
- __sincosl (__imag__ x, &sinix, &cosix);
+ if (__builtin_expect (icls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__imag__ x, &sinix, &cosix);
+ }
+ else
+ {
+ sinix = __imag__ x;
+ cosix = 1.0;
+ }
if (fabsl (__real__ x) > t)
{
diff --git a/libc/math/s_ctanl.c b/libc/math/s_ctanl.c
index 4fe26119c..0affe9321 100644
--- a/libc/math/s_ctanl.c
+++ b/libc/math/s_ctanl.c
@@ -53,11 +53,20 @@ __ctanl (__complex__ long double x)
long double sinrx, cosrx;
long double den;
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
+ int rcls = fpclassify (__real__ x);
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
- __sincosl (__real__ x, &sinrx, &cosrx);
+ if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
+ {
+ __sincosl (__real__ x, &sinrx, &cosrx);
+ }
+ else
+ {
+ sinrx = __real__ x;
+ cosrx = 1.0;
+ }
if (fabsl (__imag__ x) > t)
{