(root)/
gcc-13.2.0/
gcc/
d/
dmd/
root/
ctfloat.h
       1  
       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
       8   */
       9  
      10  #pragma once
      11  
      12  #include "dcompat.h"
      13  #include "longdouble.h"
      14  
      15  // Type used by the front-end for compile-time reals
      16  typedef longdouble real_t;
      17  
      18  // Compile-time floating-point helper
      19  struct CTFloat
      20  {
      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);
      23  
      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);
      30  
      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);
      42  
      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);
      46  
      47      static real_t fma(real_t x, real_t y, real_t z);
      48  
      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);
      53  
      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);
      56  
      57      static size_t hash(real_t a);
      58  
      59      // Constant real values 0, 1, -1 and 0.5.
      60      static real_t zero;
      61      static real_t one;
      62      static real_t minusone;
      63      static real_t half;
      64  
      65      static void initialize();
      66  };