/src/core/stdc/math.d
D | 1096 lines | 829 code | 193 blank | 74 comment | 41 complexity | 38ca15b10c94274bfa98e912ba234d6d MD5 | raw file
1/** 2 * D header file for C99. 3 * 4 * Copyright: Copyright Sean Kelly 2005 - 2012. 5 * License: Distributed under the 6 * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 * (See accompanying file LICENSE) 8 * Authors: Sean Kelly 9 * Source: $(DRUNTIMESRC core/stdc/_math.d) 10 */ 11 12module core.stdc.math; 13 14private import core.stdc.config; 15 16extern (C): 17@trusted: // All functions here operate on floating point and integer values only. 18nothrow: 19pure: 20 21alias float float_t; 22alias double double_t; 23 24enum double HUGE_VAL = double.infinity; 25enum double HUGE_VALF = float.infinity; 26enum double HUGE_VALL = real.infinity; 27 28enum float INFINITY = float.infinity; 29enum float NAN = float.nan; 30 31enum int FP_ILOGB0 = int.min; 32enum int FP_ILOGBNAN = int.min; 33 34enum int MATH_ERRNO = 1; 35enum int MATH_ERREXCEPT = 2; 36enum int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT; 37 38version( none ) 39{ 40 // 41 // these functions are all macros in C 42 // 43 44 //int fpclassify(real-floating x); 45 int fpclassify(float x); 46 int fpclassify(double x); 47 int fpclassify(real x); 48 49 //int isfinite(real-floating x); 50 int isfinite(float x); 51 int isfinite(double x); 52 int isfinite(real x); 53 54 //int isinf(real-floating x); 55 int isinf(float x); 56 int isinf(double x); 57 int isinf(real x); 58 59 //int isnan(real-floating x); 60 int isnan(float x); 61 int isnan(double x); 62 int isnan(real x); 63 64 //int isnormal(real-floating x); 65 int isnormal(float x); 66 int isnormal(double x); 67 int isnormal(real x); 68 69 //int signbit(real-floating x); 70 int signbit(float x); 71 int signbit(double x); 72 int signbit(real x); 73 74 //int isgreater(real-floating x, real-floating y); 75 int isgreater(float x, float y); 76 int isgreater(double x, double y); 77 int isgreater(real x, real y); 78 79 //int isgreaterequal(real-floating x, real-floating y); 80 int isgreaterequal(float x, float y); 81 int isgreaterequal(double x, double y); 82 int isgreaterequal(real x, real y); 83 84 //int isless(real-floating x, real-floating y); 85 int isless(float x, float y); 86 int isless(double x, double y); 87 int isless(real x, real y); 88 89 //int islessequal(real-floating x, real-floating y); 90 int islessequal(float x, float y); 91 int islessequal(double x, double y); 92 int islessequal(real x, real y); 93 94 //int islessgreater(real-floating x, real-floating y); 95 int islessgreater(float x, float y); 96 int islessgreater(double x, double y); 97 int islessgreater(real x, real y); 98 99 //int isunordered(real-floating x, real-floating y); 100 int isunordered(float x, float y); 101 int isunordered(double x, double y); 102 int isunordered(real x, real y); 103} 104 105version( DigitalMars ) 106{ 107 version( Win32 ) 108 version = DigitalMarsWin32; 109 version( Win64 ) 110 version = DigitalMarsWin64; // just to get it to compile for the moment - fix later 111} 112 113version( DigitalMarsWin32 ) 114{ 115 enum 116 { 117 FP_NANS = 0, 118 FP_NANQ = 1, 119 FP_INFINITE = 2, 120 FP_NORMAL = 3, 121 FP_SUBNORMAL = 4, 122 FP_ZERO = 5, 123 FP_NAN = FP_NANQ, 124 FP_EMPTY = 6, 125 FP_UNSUPPORTED = 7, 126 } 127 128 enum 129 { 130 FP_FAST_FMA = 0, 131 FP_FAST_FMAF = 0, 132 FP_FAST_FMAL = 0, 133 } 134 135 uint __fpclassify_f(float x); 136 uint __fpclassify_d(double x); 137 uint __fpclassify_ld(real x); 138 139 extern (D) 140 { 141 //int fpclassify(real-floating x); 142 int fpclassify(float x) { return __fpclassify_f(x); } 143 int fpclassify(double x) { return __fpclassify_d(x); } 144 int fpclassify(real x) 145 { 146 return (real.sizeof == double.sizeof) 147 ? __fpclassify_d(x) 148 : __fpclassify_ld(x); 149 } 150 151 //int isfinite(real-floating x); 152 int isfinite(float x) { return fpclassify(x) >= FP_NORMAL; } 153 int isfinite(double x) { return fpclassify(x) >= FP_NORMAL; } 154 int isfinite(real x) { return fpclassify(x) >= FP_NORMAL; } 155 156 //int isinf(real-floating x); 157 int isinf(float x) { return fpclassify(x) == FP_INFINITE; } 158 int isinf(double x) { return fpclassify(x) == FP_INFINITE; } 159 int isinf(real x) { return fpclassify(x) == FP_INFINITE; } 160 161 //int isnan(real-floating x); 162 int isnan(float x) { return fpclassify(x) <= FP_NANQ; } 163 int isnan(double x) { return fpclassify(x) <= FP_NANQ; } 164 int isnan(real x) { return fpclassify(x) <= FP_NANQ; } 165 166 //int isnormal(real-floating x); 167 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; } 168 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; } 169 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; } 170 171 //int signbit(real-floating x); 172 int signbit(float x) { return (cast(short*)&(x))[1] & 0x8000; } 173 int signbit(double x) { return (cast(short*)&(x))[3] & 0x8000; } 174 int signbit(real x) 175 { 176 return (real.sizeof == double.sizeof) 177 ? (cast(short*)&(x))[3] & 0x8000 178 : (cast(short*)&(x))[4] & 0x8000; 179 } 180 } 181} 182else version( DigitalMarsWin64 ) 183{ 184 enum 185 { 186 _FPCLASS_SNAN = 1, 187 _FPCLASS_QNAN = 2, 188 _FPCLASS_NINF = 4, 189 _FPCLASS_NN = 8, 190 _FPCLASS_ND = 0x10, 191 _FPCLASS_NZ = 0x20, 192 _FPCLASS_PZ = 0x40, 193 _FPCLASS_PD = 0x80, 194 _FPCLASS_PN = 0x100, 195 _FPCLASS_PINF = 0x200, 196 } 197 198 float _copysignf(float x, float s); 199 float _chgsignf(float x); 200 int _finitef(float x); 201 int _isnanf(float x); 202 int _fpclassf(float x); 203 204 double _copysign(double x, double s); 205 double _chgsign(double x); 206 int _finite(double x); 207 int _isnan(double x); 208 int _fpclass(double x); 209 210 extern(D) 211 { 212 int isnan(float x) { return _isnanf(x); } 213 int isnan(double x) { return _isnan(x); } 214 int isnan(real x) { return _isnan(x); } 215 } 216} 217else version( linux ) 218{ 219 enum 220 { 221 FP_NAN, 222 FP_INFINITE, 223 FP_ZERO, 224 FP_SUBNORMAL, 225 FP_NORMAL, 226 } 227 228 enum 229 { 230 FP_FAST_FMA = 0, 231 FP_FAST_FMAF = 0, 232 FP_FAST_FMAL = 0, 233 } 234 235 int __fpclassifyf(float x); 236 int __fpclassify(double x); 237 int __fpclassifyl(real x); 238 239 int __finitef(float x); 240 int __finite(double x); 241 int __finitel(real x); 242 243 int __isinff(float x); 244 int __isinf(double x); 245 int __isinfl(real x); 246 247 int __isnanf(float x); 248 int __isnan(double x); 249 int __isnanl(real x); 250 251 int __signbitf(float x); 252 int __signbit(double x); 253 int __signbitl(real x); 254 255 extern (D) 256 { 257 //int fpclassify(real-floating x); 258 int fpclassify(float x) { return __fpclassifyf(x); } 259 int fpclassify(double x) { return __fpclassify(x); } 260 int fpclassify(real x) 261 { 262 return (real.sizeof == double.sizeof) 263 ? __fpclassify(x) 264 : __fpclassifyl(x); 265 } 266 267 //int isfinite(real-floating x); 268 int isfinite(float x) { return __finitef(x); } 269 int isfinite(double x) { return __finite(x); } 270 int isfinite(real x) 271 { 272 return (real.sizeof == double.sizeof) 273 ? __finite(x) 274 : __finitel(x); 275 } 276 277 //int isinf(real-floating x); 278 int isinf(float x) { return __isinff(x); } 279 int isinf(double x) { return __isinf(x); } 280 int isinf(real x) 281 { 282 return (real.sizeof == double.sizeof) 283 ? __isinf(x) 284 : __isinfl(x); 285 } 286 287 //int isnan(real-floating x); 288 int isnan(float x) { return __isnanf(x); } 289 int isnan(double x) { return __isnan(x); } 290 int isnan(real x) 291 { 292 return (real.sizeof == double.sizeof) 293 ? __isnan(x) 294 : __isnanl(x); 295 } 296 297 //int isnormal(real-floating x); 298 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; } 299 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; } 300 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; } 301 302 //int signbit(real-floating x); 303 int signbit(float x) { return __signbitf(x); } 304 int signbit(double x) { return __signbit(x); } 305 int signbit(real x) 306 { 307 return (real.sizeof == double.sizeof) 308 ? __signbit(x) 309 : __signbitl(x); 310 } 311 } 312} 313else version( MinGW ) 314{ 315 enum 316 { 317 FP_NAN = 0x0100, 318 FP_NORMAL = 0x0400, 319 FP_INFINITE = FP_NAN | FP_NORMAL, 320 FP_ZERO = 0x0400, 321 FP_SUBNORMAL = FP_NORMAL | FP_ZERO 322 } 323 324 int __fpclassifyf(float x); 325 int __fpclassify(double x); 326 int __fpclassifyl(real x); 327 328 int __isnanf(float x); 329 int __isnan(double x); 330 int __isnanl(real x); 331 332 int __signbitf(float x); 333 int __signbit(double x); 334 int __signbitl(real x); 335 336 extern (D) 337 { 338 //int fpclassify(real-floating x); 339 int fpclassify(float x) { return __fpclassifyf(x); } 340 int fpclassify(double x) { return __fpclassify(x); } 341 int fpclassify(real x) 342 { 343 return (real.sizeof == double.sizeof) 344 ? __fpclassify(x) 345 : __fpclassifyl(x); 346 } 347 348 //int isfinite(real-floating x); 349 int isfinite(float x) { return (fpclassify(x) & FP_NORMAL) == 0; } 350 int isfinite(double x) { return (fpclassify(x) & FP_NORMAL) == 0; } 351 int isfinite(real x) { return (fpclassify(x) & FP_NORMAL) == 0; } 352 353 //int isinf(real-floating x); 354 int isinf(float x) { return fpclassify(x) == FP_INFINITE; } 355 int isinf(double x) { return fpclassify(x) == FP_INFINITE; } 356 int isinf(real x) { return fpclassify(x) == FP_INFINITE; } 357 358 //int isnan(real-floating x); 359 int isnan(float x) { return __isnanf(x); } 360 int isnan(double x) { return __isnan(x); } 361 int isnan(real x) 362 { 363 return (real.sizeof == double.sizeof) 364 ? __isnan(x) 365 : __isnanl(x); 366 } 367 368 //int isnormal(real-floating x); 369 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; } 370 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; } 371 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; } 372 373 //int signbit(real-floating x); 374 int signbit(float x) { return __signbitf(x); } 375 int signbit(double x) { return __signbit(x); } 376 int signbit(real x) 377 { 378 return (real.sizeof == double.sizeof) 379 ? __signbit(x) 380 : __signbitl(x); 381 } 382 } 383} 384else version( OSX ) 385{ 386 enum 387 { 388 FP_NAN = 1, 389 FP_INFINITE = 2, 390 FP_ZERO = 3, 391 FP_NORMAL = 4, 392 FP_SUBNORMAL = 5, 393 FP_SUPERNORMAL = 6, 394 } 395 396 enum 397 { 398 FP_FAST_FMA = 0, 399 FP_FAST_FMAF = 0, 400 FP_FAST_FMAL = 0, 401 } 402 403 int __fpclassifyf(float x); 404 int __fpclassifyd(double x); 405 int __fpclassify(real x); 406 407 int __isfinitef(float x); 408 int __isfinited(double x); 409 int __isfinite(real x); 410 411 int __isinff(float x); 412 int __isinfd(double x); 413 int __isinf(real x); 414 415 int __isnanf(float x); 416 int __isnand(double x); 417 int __isnan(real x); 418 419 int __signbitf(float x); 420 int __signbitd(double x); 421 int __signbitl(real x); 422 423 extern (D) 424 { 425 //int fpclassify(real-floating x); 426 int fpclassify(float x) { return __fpclassifyf(x); } 427 int fpclassify(double x) { return __fpclassifyd(x); } 428 int fpclassify(real x) 429 { 430 return (real.sizeof == double.sizeof) 431 ? __fpclassifyd(x) 432 : __fpclassify(x); 433 } 434 435 //int isfinite(real-floating x); 436 int isfinite(float x) { return __isfinitef(x); } 437 int isfinite(double x) { return __isfinited(x); } 438 int isfinite(real x) 439 { 440 return (real.sizeof == double.sizeof) 441 ? __isfinited(x) 442 : __isfinite(x); 443 } 444 445 //int isinf(real-floating x); 446 int isinf(float x) { return __isinff(x); } 447 int isinf(double x) { return __isinfd(x); } 448 int isinf(real x) 449 { 450 return (real.sizeof == double.sizeof) 451 ? __isinfd(x) 452 : __isinf(x); 453 } 454 455 //int isnan(real-floating x); 456 int isnan(float x) { return __isnanf(x); } 457 int isnan(double x) { return __isnand(x); } 458 int isnan(real x) 459 { 460 return (real.sizeof == double.sizeof) 461 ? __isnand(x) 462 : __isnan(x); 463 } 464 465 //int isnormal(real-floating x); 466 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; } 467 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; } 468 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; } 469 470 //int signbit(real-floating x); 471 int signbit(float x) { return __signbitf(x); } 472 int signbit(double x) { return __signbitd(x); } 473 int signbit(real x) 474 { 475 return (real.sizeof == double.sizeof) 476 ? __signbitd(x) 477 : __signbitl(x); 478 } 479 } 480} 481else version( FreeBSD ) 482{ 483 enum 484 { 485 FP_INFINITE = 0x01, 486 FP_NAN = 0x02, 487 FP_NORMAL = 0x04, 488 FP_SUBNORMAL = 0x08, 489 FP_ZERO = 0x10, 490 } 491 492 enum 493 { 494 FP_FAST_FMA = 0, 495 FP_FAST_FMAF = 0, 496 FP_FAST_FMAL = 0, 497 } 498 499 int __fpclassifyd(double); 500 int __fpclassifyf(float); 501 int __fpclassifyl(real); 502 int __isfinitef(float); 503 int __isfinite(double); 504 int __isfinitel(real); 505 int __isinff(float); 506 int __isinfl(real); 507 int __isnanl(real); 508 int __isnormalf(float); 509 int __isnormal(double); 510 int __isnormall(real); 511 int __signbit(double); 512 int __signbitf(float); 513 int __signbitl(real); 514 515 extern (D) 516 { 517 //int fpclassify(real-floating x); 518 int fpclassify(float x) { return __fpclassifyf(x); } 519 int fpclassify(double x) { return __fpclassifyd(x); } 520 int fpclassify(real x) { return __fpclassifyl(x); } 521 522 //int isfinite(real-floating x); 523 int isfinite(float x) { return __isfinitef(x); } 524 int isfinite(double x) { return __isfinite(x); } 525 int isfinite(real x) { return __isfinitel(x); } 526 527 //int isinf(real-floating x); 528 int isinf(float x) { return __isinff(x); } 529 int isinf(double x) { return __isinfl(x); } 530 int isinf(real x) { return __isinfl(x); } 531 532 //int isnan(real-floating x); 533 int isnan(float x) { return __isnanl(x); } 534 int isnan(double x) { return __isnanl(x); } 535 int isnan(real x) { return __isnanl(x); } 536 537 //int isnormal(real-floating x); 538 int isnormal(float x) { return __isnormalf(x); } 539 int isnormal(double x) { return __isnormal(x); } 540 int isnormal(real x) { return __isnormall(x); } 541 542 //int signbit(real-floating x); 543 int signbit(float x) { return __signbitf(x); } 544 int signbit(double x) { return __signbit(x); } 545 int signbit(real x) { return __signbit(x); } 546 } 547} 548 549extern (D) 550{ 551 //int isgreater(real-floating x, real-floating y); 552 int isgreater(float x, float y) { return !(x !> y); } 553 int isgreater(double x, double y) { return !(x !> y); } 554 int isgreater(real x, real y) { return !(x !> y); } 555 556 //int isgreaterequal(real-floating x, real-floating y); 557 int isgreaterequal(float x, float y) { return !(x !>= y); } 558 int isgreaterequal(double x, double y) { return !(x !>= y); } 559 int isgreaterequal(real x, real y) { return !(x !>= y); } 560 561 //int isless(real-floating x, real-floating y); 562 int isless(float x, float y) { return !(x !< y); } 563 int isless(double x, double y) { return !(x !< y); } 564 int isless(real x, real y) { return !(x !< y); } 565 566 //int islessequal(real-floating x, real-floating y); 567 int islessequal(float x, float y) { return !(x !<= y); } 568 int islessequal(double x, double y) { return !(x !<= y); } 569 int islessequal(real x, real y) { return !(x !<= y); } 570 571 //int islessgreater(real-floating x, real-floating y); 572 int islessgreater(float x, float y) { return !(x !<> y); } 573 int islessgreater(double x, double y) { return !(x !<> y); } 574 int islessgreater(real x, real y) { return !(x !<> y); } 575 576 //int isunordered(real-floating x, real-floating y); 577 int isunordered(float x, float y) { return (x !<>= y); } 578 int isunordered(double x, double y) { return (x !<>= y); } 579 int isunordered(real x, real y) { return (x !<>= y); } 580} 581 582/* NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can 583 * approximate. 584 * A lot of them were added in 8.0-RELEASE, and so a lot of these workarounds 585 * should then be removed. 586 */ 587// NOTE: FreeBSD 8.0-RELEASE doesn't support log2* nor these *l functions: 588// acoshl, asinhl, atanhl, coshl, sinhl, tanhl, cbrtl, powl, expl, 589// expm1l, logl, log1pl, log10l, erfcl, erfl, lgammal, tgammal; 590// but we can approximate. 591version( FreeBSD ) 592{ 593 version (none) // < 8-CURRENT 594 { 595 real acosl(real x) { return acos(x); } 596 real asinl(real x) { return asin(x); } 597 real atanl(real x) { return atan(x); } 598 real atan2l(real y, real x) { return atan2(y, x); } 599 real cosl(real x) { return cos(x); } 600 real sinl(real x) { return sin(x); } 601 real tanl(real x) { return tan(x); } 602 real exp2l(real x) { return exp2(x); } 603 real frexpl(real value, int* exp) { return frexp(value, exp); } 604 int ilogbl(real x) { return ilogb(x); } 605 real ldexpl(real x, int exp) { return ldexp(x, exp); } 606 real logbl(real x) { return logb(x); } 607 //real modfl(real value, real *iptr); // nontrivial conversion 608 real scalbnl(real x, int n) { return scalbn(x, n); } 609 real scalblnl(real x, c_long n) { return scalbln(x, n); } 610 real fabsl(real x) { return fabs(x); } 611 real hypotl(real x, real y) { return hypot(x, y); } 612 real sqrtl(real x) { return sqrt(x); } 613 real ceill(real x) { return ceil(x); } 614 real floorl(real x) { return floor(x); } 615 real nearbyintl(real x) { return nearbyint(x); } 616 real rintl(real x) { return rint(x); } 617 c_long lrintl(real x) { return lrint(x); } 618 real roundl(real x) { return round(x); } 619 c_long lroundl(real x) { return lround(x); } 620 long llroundl(real x) { return llround(x); } 621 real truncl(real x) { return trunc(x); } 622 real fmodl(real x, real y) { return fmod(x, y); } 623 real remainderl(real x, real y) { return remainder(x, y); } 624 real remquol(real x, real y, int* quo) { return remquo(x, y, quo); } 625 real copysignl(real x, real y) { return copysign(x, y); } 626// double nan(char* tagp); 627// float nanf(char* tagp); 628// real nanl(char* tagp); 629 real nextafterl(real x, real y) { return nextafter(x, y); } 630 real nexttowardl(real x, real y) { return nexttoward(x, y); } 631 real fdiml(real x, real y) { return fdim(x, y); } 632 real fmaxl(real x, real y) { return fmax(x, y); } 633 real fminl(real x, real y) { return fmin(x, y); } 634 real fmal(real x, real y, real z) { return fma(x, y, z); } 635 } 636 else 637 { 638 real acosl(real x); 639 real asinl(real x); 640 real atanl(real x); 641 real atan2l(real y, real x); 642 real cosl(real x); 643 real sinl(real x); 644 real tanl(real x); 645 real exp2l(real x); 646 real frexpl(real value, int* exp); 647 int ilogbl(real x); 648 real ldexpl(real x, int exp); 649 real logbl(real x); 650 real modfl(real value, real *iptr); 651 real scalbnl(real x, int n); 652 real scalblnl(real x, c_long n); 653 real fabsl(real x); 654 real hypotl(real x, real y); 655 real sqrtl(real x); 656 real ceill(real x); 657 real floorl(real x); 658 real nearbyintl(real x); 659 real rintl(real x); 660 c_long lrintl(real x); 661 real roundl(real x); 662 c_long lroundl(real x); 663 long llroundl(real x); 664 real truncl(real x); 665 real fmodl(real x, real y); 666 real remainderl(real x, real y); 667 real remquol(real x, real y, int* quo); 668 real copysignl(real x, real y); 669 double nan(char* tagp); 670 float nanf(char* tagp); 671 real nanl(char* tagp); 672 real nextafterl(real x, real y); 673 real nexttowardl(real x, real y); 674 real fdiml(real x, real y); 675 real fmaxl(real x, real y); 676 real fminl(real x, real y); 677 real fmal(real x, real y, real z); 678 } 679 double acos(double x); 680 float acosf(float x); 681 682 double asin(double x); 683 float asinf(float x); 684 685 double atan(double x); 686 float atanf(float x); 687 688 double atan2(double y, double x); 689 float atan2f(float y, float x); 690 691 double cos(double x); 692 float cosf(float x); 693 694 double sin(double x); 695 float sinf(float x); 696 697 double tan(double x); 698 float tanf(float x); 699 700 double acosh(double x); 701 float acoshf(float x); 702 real acoshl(real x) { return acosh(x); } 703 704 double asinh(double x); 705 float asinhf(float x); 706 real asinhl(real x) { return asinh(x); } 707 708 double atanh(double x); 709 float atanhf(float x); 710 real atanhl(real x) { return atanh(x); } 711 712 double cosh(double x); 713 float coshf(float x); 714 real coshl(real x) { return cosh(x); } 715 716 double sinh(double x); 717 float sinhf(float x); 718 real sinhl(real x) { return sinh(x); } 719 720 double tanh(double x); 721 float tanhf(float x); 722 real tanhl(real x) { return tanh(x); } 723 724 double exp(double x); 725 float expf(float x); 726 real expl(real x) { return exp(x); } 727 728 double exp2(double x); 729 float exp2f(float x); 730 731 double expm1(double x); 732 float expm1f(float x); 733 real expm1l(real x) { return expm1(x); } 734 735 double frexp(double value, int* exp); 736 float frexpf(float value, int* exp); 737 738 int ilogb(double x); 739 int ilogbf(float x); 740 741 double ldexp(double x, int exp); 742 float ldexpf(float x, int exp); 743 744 double log(double x); 745 float logf(float x); 746 real logl(real x) { return log(x); } 747 748 double log10(double x); 749 float log10f(float x); 750 real log10l(real x) { return log10(x); } 751 752 double log1p(double x); 753 float log1pf(float x); 754 real log1pl(real x) { return log1p(x); } 755 756 private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L; 757 double log2(double x) { return log(x) * ONE_LN2; } 758 float log2f(float x) { return logf(x) * ONE_LN2; } 759 real log2l(real x) { return logl(x) * ONE_LN2; } 760 761 double logb(double x); 762 float logbf(float x); 763 764 double modf(double value, double* iptr); 765 float modff(float value, float* iptr); 766 767 double scalbn(double x, int n); 768 float scalbnf(float x, int n); 769 770 double scalbln(double x, c_long n); 771 float scalblnf(float x, c_long n); 772 773 double cbrt(double x); 774 float cbrtf(float x); 775 real cbrtl(real x) { return cbrt(x); } 776 777 double fabs(double x); 778 float fabsf(float x); 779 780 double hypot(double x, double y); 781 float hypotf(float x, float y); 782 783 double pow(double x, double y); 784 float powf(float x, float y); 785 real powl(real x, real y) { return pow(x, y); } 786 787 double sqrt(double x); 788 float sqrtf(float x); 789 790 double erf(double x); 791 float erff(float x); 792 real erfl(real x) { return erf(x); } 793 794 double erfc(double x); 795 float erfcf(float x); 796 real erfcl(real x) { return erfc(x); } 797 798 double lgamma(double x); 799 float lgammaf(float x); 800 real lgammal(real x) { return lgamma(x); } 801 802 double tgamma(double x); 803 float tgammaf(float x); 804 real tgammal(real x) { return tgamma(x); } 805 806 double ceil(double x); 807 float ceilf(float x); 808 809 double floor(double x); 810 float floorf(float x); 811 812 double nearbyint(double x); 813 float nearbyintf(float x); 814 815 double rint(double x); 816 float rintf(float x); 817 818 c_long lrint(double x); 819 c_long lrintf(float x); 820 821 long llrint(double x); 822 long llrintf(float x); 823 long llrintl(real x) { return llrint(x); } 824 825 double round(double x); 826 float roundf(float x); 827 828 c_long lround(double x); 829 c_long lroundf(float x); 830 831 long llround(double x); 832 long llroundf(float x); 833 834 double trunc(double x); 835 float truncf(float x); 836 837 double fmod(double x, double y); 838 float fmodf(float x, float y); 839 840 double remainder(double x, double y); 841 float remainderf(float x, float y); 842 843 double remquo(double x, double y, int* quo); 844 float remquof(float x, float y, int* quo); 845 846 double copysign(double x, double y); 847 float copysignf(float x, float y); 848 849 double nextafter(double x, double y); 850 float nextafterf(float x, float y); 851 852 double nexttoward(double x, real y); 853 float nexttowardf(float x, real y); 854 855 double fdim(double x, double y); 856 float fdimf(float x, float y); 857 858 double fmax(double x, double y); 859 float fmaxf(float x, float y); 860 861 double fmin(double x, double y); 862 float fminf(float x, float y); 863 864 double fma(double x, double y, double z); 865 float fmaf(float x, float y, float z); 866} 867else 868{ 869 double acos(double x); 870 float acosf(float x); 871 real acosl(real x); 872 873 double asin(double x); 874 float asinf(float x); 875 real asinl(real x); 876 877 double atan(double x); 878 float atanf(float x); 879 real atanl(real x); 880 881 double atan2(double y, double x); 882 float atan2f(float y, float x); 883 real atan2l(real y, real x); 884 885 double cos(double x); 886 float cosf(float x); 887 real cosl(real x); 888 889 double sin(double x); 890 float sinf(float x); 891 real sinl(real x); 892 893 double tan(double x); 894 float tanf(float x); 895 real tanl(real x); 896 897 double acosh(double x); 898 float acoshf(float x); 899 real acoshl(real x); 900 901 double asinh(double x); 902 float asinhf(float x); 903 real asinhl(real x); 904 905 double atanh(double x); 906 float atanhf(float x); 907 real atanhl(real x); 908 909 double cosh(double x); 910 float coshf(float x); 911 real coshl(real x); 912 913 double sinh(double x); 914 float sinhf(float x); 915 real sinhl(real x); 916 917 double tanh(double x); 918 float tanhf(float x); 919 real tanhl(real x); 920 921 double exp(double x); 922 float expf(float x); 923 real expl(real x); 924 925 double exp2(double x); 926 float exp2f(float x); 927 real exp2l(real x); 928 929 double expm1(double x); 930 float expm1f(float x); 931 real expm1l(real x); 932 933 double frexp(double value, int* exp); 934 float frexpf(float value, int* exp); 935 real frexpl(real value, int* exp); 936 937 int ilogb(double x); 938 int ilogbf(float x); 939 int ilogbl(real x); 940 941 double ldexp(double x, int exp); 942 float ldexpf(float x, int exp); 943 real ldexpl(real x, int exp); 944 945 double log(double x); 946 float logf(float x); 947 real logl(real x); 948 949 double log10(double x); 950 float log10f(float x); 951 real log10l(real x); 952 953 double log1p(double x); 954 float log1pf(float x); 955 real log1pl(real x); 956 957 double log2(double x); 958 float log2f(float x); 959 real log2l(real x); 960 961 double logb(double x); 962 float logbf(float x); 963 real logbl(real x); 964 965 double modf(double value, double* iptr); 966 float modff(float value, float* iptr); 967 real modfl(real value, real *iptr); 968 969 double scalbn(double x, int n); 970 float scalbnf(float x, int n); 971 real scalbnl(real x, int n); 972 973 double scalbln(double x, c_long n); 974 float scalblnf(float x, c_long n); 975 real scalblnl(real x, c_long n); 976 977 double cbrt(double x); 978 float cbrtf(float x); 979 real cbrtl(real x); 980 981 double fabs(double x); 982 float fabsf(float x); 983 real fabsl(real x); 984 985 double hypot(double x, double y); 986 float hypotf(float x, float y); 987 real hypotl(real x, real y); 988 989 double pow(double x, double y); 990 float powf(float x, float y); 991 real powl(real x, real y); 992 993 double sqrt(double x); 994 float sqrtf(float x); 995 real sqrtl(real x); 996 997 double erf(double x); 998 float erff(float x); 999 real erfl(real x); 1000 1001 double erfc(double x); 1002 float erfcf(float x); 1003 real erfcl(real x); 1004 1005 double lgamma(double x); 1006 float lgammaf(float x); 1007 real lgammal(real x); 1008 1009 double tgamma(double x); 1010 float tgammaf(float x); 1011 real tgammal(real x); 1012 1013 double ceil(double x); 1014 float ceilf(float x); 1015 real ceill(real x); 1016 1017 double floor(double x); 1018 float floorf(float x); 1019 real floorl(real x); 1020 1021 double nearbyint(double x); 1022 float nearbyintf(float x); 1023 real nearbyintl(real x); 1024 1025 double rint(double x); 1026 float rintf(float x); 1027 real rintl(real x); 1028 1029 c_long lrint(double x); 1030 c_long lrintf(float x); 1031 c_long lrintl(real x); 1032 1033 long llrint(double x); 1034 long llrintf(float x); 1035 long llrintl(real x); 1036 1037 double round(double x); 1038 float roundf(float x); 1039 real roundl(real x); 1040 1041 c_long lround(double x); 1042 c_long lroundf(float x); 1043 c_long lroundl(real x); 1044 1045 long llround(double x); 1046 long llroundf(float x); 1047 long llroundl(real x); 1048 1049 double trunc(double x); 1050 float truncf(float x); 1051 real truncl(real x); 1052 1053 double fmod(double x, double y); 1054 float fmodf(float x, float y); 1055 real fmodl(real x, real y); 1056 1057 double remainder(double x, double y); 1058 float remainderf(float x, float y); 1059 real remainderl(real x, real y); 1060 1061 double remquo(double x, double y, int* quo); 1062 float remquof(float x, float y, int* quo); 1063 real remquol(real x, real y, int* quo); 1064 1065 double copysign(double x, double y); 1066 float copysignf(float x, float y); 1067 real copysignl(real x, real y); 1068 1069 double nan(char* tagp); 1070 float nanf(char* tagp); 1071 real nanl(char* tagp); 1072 1073 double nextafter(double x, double y); 1074 float nextafterf(float x, float y); 1075 real nextafterl(real x, real y); 1076 1077 double nexttoward(double x, real y); 1078 float nexttowardf(float x, real y); 1079 real nexttowardl(real x, real y); 1080 1081 double fdim(double x, double y); 1082 float fdimf(float x, float y); 1083 real fdiml(real x, real y); 1084 1085 double fmax(double x, double y); 1086 float fmaxf(float x, float y); 1087 real fmaxl(real x, real y); 1088 1089 double fmin(double x, double y); 1090 float fminf(float x, float y); 1091 real fminl(real x, real y); 1092 1093 double fma(double x, double y, double z); 1094 float fmaf(float x, float y, float z); 1095 real fmal(real x, real y, real z); 1096}