d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / root / ctfloat.d
blob70446066593d58c6f81db945e88cc9cd439d93fa
1 /**
2 * Collects functions for compile-time floating-point calculations.
4 * Copyright: Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
5 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
6 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/ctfloat.d, root/_ctfloat.d)
8 * Documentation: https://dlang.org/phobos/dmd_root_ctfloat.html
9 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/ctfloat.d
12 module dmd.root.ctfloat;
14 nothrow:
16 // Type used by the front-end for compile-time reals
17 public import dmd.root.longdouble : real_t = longdouble;
19 // Compile-time floating-point helper
20 extern (C++) struct CTFloat
22 nothrow:
23 @nogc:
24 @safe:
26 version (GNU)
27 enum yl2x_supported = false;
28 else
29 enum yl2x_supported = __traits(compiles, core.math.yl2x(1.0L, 2.0L));
30 enum yl2xp1_supported = yl2x_supported;
32 pure static real_t fabs(real_t x);
33 pure static real_t ldexp(real_t n, int exp);
35 pure @trusted
36 static bool isIdentical(real_t a, real_t b);
38 pure @trusted
39 static size_t hash(real_t a);
41 pure
42 static bool isNaN(real_t r);
44 pure @trusted
45 static bool isSNaN(real_t r);
47 static bool isInfinity(real_t r) pure;
49 @system
50 static real_t parse(const(char)* literal, out bool isOutOfRange);
52 @system
53 static int sprint(char* str, size_t size, char fmt, real_t x);
55 // Constant real values 0, 1, -1 and 0.5.
56 __gshared real_t zero;
57 __gshared real_t one;
58 __gshared real_t minusone;
59 __gshared real_t half;
61 @trusted
62 static void initialize();