File: Math.c

package info (click to toggle)
mlton 20061107-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,828 kB
  • ctags: 61,118
  • sloc: ansic: 11,446; makefile: 1,339; sh: 1,160; lisp: 900; pascal: 256; asm: 97
file content (57 lines) | stat: -rw-r--r-- 2,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "platform.h"

#define unaryReal(f, g)                                         \
        Real64 g (Real64 x);                                    \
        Real64 Real64_##f (Real64 x) {          \
                return g (x);                                   \
        }                                                       \
        Real32 Real32_##f (Real32 x) {          \
                return (Real32)(Real64_##f ((Real64)x));        \
        }
unaryReal(abs, fabs)
unaryReal(round, rint)
#undef unaryReal

#define binaryReal(f, g)                                                        \
        Real64 g (Real64 x, Real64 y);                                          \
        Real64 Real64_Math_##f (Real64 x, Real64 y) {           \
                return g (x, y);                                                \
        }                                                                       \
        Real32 Real32_Math_##f (Real32 x, Real32 y) {           \
                return (Real32)(Real64_Math_##f ((Real64)x, (Real64)y));        \
        }
binaryReal(atan2, atan2)
binaryReal(pow, pow)
#undef binaryReal

#define unaryReal(f, g)                                         \
        Real64 g (Real64 x);                                    \
        Real64 Real64_Math_##f (Real64 x) {     \
                return g (x);                                   \
        }                                                       \
        Real32 Real32_Math_##f (Real32 x) {     \
                return (Real32)(Real64_Math_##f ((Real64)x));   \
        }
unaryReal(acos, acos)
unaryReal(asin, asin)
unaryReal(atan, atan)
unaryReal(cos, cos)
unaryReal(cosh, cosh)
unaryReal(exp, exp)
unaryReal(ln, log)
unaryReal(log10, log10)
unaryReal(sin, sin)
unaryReal(sinh, sinh)
unaryReal(sqrt, sqrt)
unaryReal(tan, tan)
unaryReal(tanh, tanh)
#undef unaryReal

double ldexp (double x, int i);
Real64 Real64_ldexp (Real64 x, Int32 i) {
        return ldexp (x, i);
}

Real32 Real32_ldexp (Real32 x, Int32 i) {
        return (Real32)Real64_ldexp ((Real64)x, i);
}