WIN32/64 only: Added C99 math functions: tgamma(), tgammaf(), lgamma(), lgammaf(), cbrt(), cbrtf(), log2(), log2f(), exp2(), exp2f().

The gamma() functions are accurate to 13 digits over the full range. Returns INFINITY / NAN identical to other compiler's math libs.

#include <stdio.h>
#include <math.h>

int main() {
  double x;
  for (x = -7.0; x <= 520.0; x += 1.0) {
    printf("tgamma/lgamma %6.3f: %20.13g  %20.13g\n", x/3, tgamma(x/3.0), lgamma(x/3.0));
  }
  printf("tgamma/lgamma %g: %20.13g  %20.13g\n", 0.00000234, tgamma(0.00000234), lgamma(0.00000234));
  printf("log2, exp2, cbrt, cbrt: %.15g %.15g %.15g %.15g\n", log2(1024), exp2(10), cbrt(-10), cbrt(10));
}
This commit is contained in:
Tyge Løvset
2020-11-14 00:02:58 +01:00
parent 08d8015750
commit 1073b379c8
2 changed files with 68 additions and 0 deletions

3
.gitignore vendored
View File

@@ -31,13 +31,16 @@ tcc-doc.html
tcc-doc.info
win32/doc
win32/examples/libtcc_test.c
win32/libtcc
win32/lib/32
win32/lib/64
win32/include/float.h
win32/include/stdalign.h
win32/include/stdarg.h
win32/include/stdbool.h
win32/include/stddef.h
win32/include/stdnoreturn.h
win32/include/varargs.h
win32/include/tcclib.h