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