2 /* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
3 * written by Walter Bright
4 * https://www.digitalmars.com
5 * Distributed under the Boost Software License, Version 1.0.
6 * https://www.boost.org/LICENSE_1_0.txt
7 * https://github.com/dlang/dmd/blob/master/src/dmd/root/ctfloat.h
13 #include "longdouble.h"
15 // Type used by the front-end for compile-time reals
16 typedef longdouble real_t
;
18 // Compile-time floating-point helper
21 static void yl2x(const real_t
*x
, const real_t
*y
, real_t
*res
);
22 static void yl2xp1(const real_t
*x
, const real_t
*y
, real_t
*res
);
24 static real_t
sin(real_t x
);
25 static real_t
cos(real_t x
);
26 static real_t
tan(real_t x
);
27 static real_t
sqrt(real_t x
);
28 static real_t
fabs(real_t x
);
29 static real_t
ldexp(real_t n
, int exp
);
31 static real_t
round(real_t x
);
32 static real_t
floor(real_t x
);
33 static real_t
ceil(real_t x
);
34 static real_t
trunc(real_t x
);
35 static real_t
log(real_t x
);
36 static real_t
log2(real_t x
);
37 static real_t
log10(real_t x
);
38 static real_t
pow(real_t x
, real_t y
);
39 static real_t
exp(real_t x
);
40 static real_t
expm1(real_t x
);
41 static real_t
exp2(real_t x
);
43 static real_t
fmin(real_t x
, real_t y
);
44 static real_t
fmax(real_t x
, real_t y
);
45 static real_t
copysign(real_t x
, real_t s
);
47 static real_t
fma(real_t x
, real_t y
, real_t z
);
49 static bool isIdentical(real_t a
, real_t b
);
50 static bool isNaN(real_t r
);
51 static bool isSNaN(real_t r
);
52 static bool isInfinity(real_t r
);
54 static real_t
parse(const char *literal
, bool& isOutOfRange
);
55 static int sprint(char *str
, d_size_t size
, char fmt
, real_t x
);
57 static size_t hash(real_t a
);
59 // Constant real values 0, 1, -1 and 0.5.
62 static real_t minusone
;
65 static void initialize();