]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | /* Gcbuiltin.c provides access to some math intrinsic functions. |
2 | ||
a945c346 | 3 | Copyright (C) 2016-2024 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius@glam.ac.uk>. |
5 | ||
6 | This file is part of GNU Modula-2. | |
7 | ||
8 | GNU Modula-2 is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GNU Modula-2 is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GNU Modula-2; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #include "Gcbuiltin.h" | |
23 | ||
24 | #include "config.h" | |
25 | #include "system.h" | |
26 | ||
27 | #define exp1 2.7182818284590452353602874713526624977572f | |
28 | ||
29 | double | |
30 | cbuiltin_sqrt (double x) | |
31 | { | |
32 | return sqrt (x); | |
33 | } | |
34 | ||
35 | long double | |
36 | cbuiltin_sqrtl (long double x) | |
37 | { | |
38 | return sqrtl (x); | |
39 | } | |
40 | ||
41 | float | |
42 | cbuiltin_sqrtf (float x) | |
43 | { | |
44 | return sqrtf (x); | |
45 | } | |
46 | ||
47 | double | |
48 | cbuiltin_exp (double x) | |
49 | { | |
50 | return exp (x); | |
51 | } | |
52 | ||
53 | float | |
54 | cbuiltin_expf (float x) | |
55 | { | |
56 | return expf (x); | |
57 | } | |
58 | ||
59 | long double | |
60 | cbuiltin_expl (long double x) | |
61 | { | |
62 | return expl (x); | |
63 | } | |
64 | ||
65 | /* calculcate ln from log. */ | |
66 | ||
67 | double | |
68 | cbuiltin_ln (double x) | |
69 | { | |
70 | return log (x) / log (exp1); | |
71 | } | |
72 | ||
73 | float | |
74 | cbuiltin_lnf (float x) | |
75 | { | |
76 | return logf (x) / logf (exp1); | |
77 | } | |
78 | ||
79 | long double | |
80 | cbuiltin_lnl (long double x) | |
81 | { | |
82 | return logl (x) / logl (exp1); | |
83 | } | |
84 | ||
85 | double | |
86 | cbuiltin_sin (double x) | |
87 | { | |
88 | return sin (x); | |
89 | } | |
90 | ||
91 | long double | |
92 | cbuiltin_sinl (long double x) | |
93 | { | |
94 | return sinl (x); | |
95 | } | |
96 | ||
97 | float | |
98 | cbuiltin_sinf (float x) | |
99 | { | |
100 | return sinf (x); | |
101 | } | |
102 | ||
103 | double | |
104 | cbuiltin_cos (double x) | |
105 | { | |
106 | return cos (x); | |
107 | } | |
108 | ||
109 | float | |
110 | cbuiltin_cosf (float x) | |
111 | { | |
112 | return cosf (x); | |
113 | } | |
114 | ||
115 | long double | |
116 | cbuiltin_cosl (long double x) | |
117 | { | |
118 | return cosl (x); | |
119 | } | |
120 | ||
121 | double | |
122 | cbuiltin_tan (double x) | |
123 | { | |
124 | return tan (x); | |
125 | } | |
126 | ||
127 | long double | |
128 | cbuiltin_tanl (long double x) | |
129 | { | |
130 | return tanl (x); | |
131 | } | |
132 | ||
133 | float | |
134 | cbuiltin_tanf (float x) | |
135 | { | |
136 | return tanf (x); | |
137 | } | |
138 | ||
139 | double | |
140 | cbuiltin_arctan (double x) | |
141 | { | |
142 | return atan (x); | |
143 | } | |
144 | ||
145 | float | |
146 | cbuiltin_arctanf (float x) | |
147 | { | |
148 | return atanf (x); | |
149 | } | |
150 | ||
151 | long double | |
152 | arctanl (long double x) | |
153 | { | |
154 | return atanl (x); | |
155 | } | |
156 | ||
157 | int | |
158 | cbuiltin_entier (double x) | |
159 | { | |
160 | return (int)floor (x); | |
161 | } | |
162 | ||
163 | int | |
164 | cbuiltin_entierf (float x) | |
165 | { | |
166 | return (int)floorf (x); | |
167 | } | |
168 | ||
169 | int | |
170 | cbuiltin_entierl (long double x) | |
171 | { | |
172 | return (int)floorl (x); | |
173 | } |