update readme (#21797)
[mono-project.git] / mono / metadata / sysmath.c
blob859da53956410fefe49c1dc176a5e17a9169b35c
1 /**
2 * \file
3 * these are based on bob smith's csharp routines
5 * Author:
6 * Mono Project (http://www.mono-project.com)
7 * Ludovic Henry (ludovic@xamarin.com)
9 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
10 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
11 * Copyright 2015 Xamarin, Inc (https://www.xamarin.com)
12 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
16 // Copyright (c) Microsoft. All rights reserved.
17 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
19 // Files:
20 // - src/classlibnative/float/floatnative.cpp
21 // - src/pal/src/cruntime/floatnative.cpp
23 // Ported from C++ to C and adjusted to Mono runtime
25 #define __USE_ISOC99
27 #include <math.h>
29 #include "number-ms.h"
30 #include "utils/mono-compiler.h"
31 #include "utils/mono-math.h"
32 #include "icalls.h"
33 #include "icall-decl.h"
35 gdouble
36 ves_icall_System_Math_Floor (gdouble x)
38 return floor(x);
41 gdouble
42 ves_icall_System_Math_Round (gdouble x)
44 return mono_round_to_even (x);
47 gdouble
48 ves_icall_System_Math_FMod (gdouble x, gdouble y)
50 return fmod (x, y);
53 gdouble
54 ves_icall_System_Math_ModF (gdouble x, gdouble *d)
56 return modf (x, d);
59 gdouble
60 ves_icall_System_Math_Sin (gdouble x)
62 return sin (x);
65 gdouble
66 ves_icall_System_Math_Cos (gdouble x)
68 return cos (x);
71 gdouble
72 ves_icall_System_Math_Cbrt (gdouble x)
74 return cbrt (x);
77 gdouble
78 ves_icall_System_Math_Tan (gdouble x)
80 return tan (x);
83 gdouble
84 ves_icall_System_Math_Sinh (gdouble x)
86 return sinh (x);
89 gdouble
90 ves_icall_System_Math_Cosh (gdouble x)
92 return cosh (x);
95 gdouble
96 ves_icall_System_Math_Tanh (gdouble x)
98 return tanh (x);
101 gdouble
102 ves_icall_System_Math_Acos (gdouble x)
104 return acos (x);
107 gdouble
108 ves_icall_System_Math_Acosh (gdouble x)
110 return acosh (x);
113 gdouble
114 ves_icall_System_Math_Asin (gdouble x)
116 return asin (x);
119 gdouble
120 ves_icall_System_Math_Asinh (gdouble x)
122 return asinh (x);
125 gdouble
126 ves_icall_System_Math_Atan (gdouble x)
128 return atan (x);
131 gdouble
132 ves_icall_System_Math_Atan2 (gdouble y, gdouble x)
134 return atan2 (y, x);
137 gdouble
138 ves_icall_System_Math_Atanh (gdouble x)
140 return atanh (x);
143 gdouble
144 ves_icall_System_Math_Exp (gdouble x)
146 return exp (x);
149 gdouble
150 ves_icall_System_Math_Log (gdouble x)
152 return log (x);
155 gdouble
156 ves_icall_System_Math_Log10 (gdouble x)
158 return log10 (x);
161 gdouble
162 ves_icall_System_Math_Pow (gdouble x, gdouble y)
164 return pow (x, y);
167 gdouble
168 ves_icall_System_Math_Sqrt (gdouble x)
170 return sqrt (x);
173 gdouble
174 ves_icall_System_Math_Abs_double (gdouble v)
176 return fabs (v);
179 float
180 ves_icall_System_Math_Abs_single (float v)
182 return fabsf (v);
185 gdouble
186 ves_icall_System_Math_Ceiling (gdouble v)
188 return ceil (v);
192 float
193 ves_icall_System_MathF_Acos (float x)
195 return acosf (x);
198 float
199 ves_icall_System_MathF_Acosh (float x)
201 return acoshf (x);
204 float
205 ves_icall_System_MathF_Asin (float x)
207 return asinf (x);
210 float
211 ves_icall_System_MathF_Asinh (float x)
213 return asinhf (x);
216 float
217 ves_icall_System_MathF_Atan (float x)
219 return atan (x);
222 float
223 ves_icall_System_MathF_Atan2 (float x, float y)
225 return atan2f (x, y);
228 float
229 ves_icall_System_MathF_Atanh (float x)
231 return atanhf (x);
234 float
235 ves_icall_System_MathF_Cbrt (float x)
237 return cbrtf (x);
240 float
241 ves_icall_System_MathF_Ceiling (float x)
243 return ceilf(x);
246 float
247 ves_icall_System_MathF_Cos (float x)
249 return cosf (x);
252 float
253 ves_icall_System_MathF_Cosh (float x)
255 return coshf (x);
258 float
259 ves_icall_System_MathF_Exp (float x)
261 return expf (x);
264 float
265 ves_icall_System_MathF_Floor (float x)
267 return floorf (x);
270 float
271 ves_icall_System_MathF_Log (float x)
273 return logf (x);
276 float
277 ves_icall_System_MathF_Log10 (float x)
279 return log10f (x);
282 float
283 ves_icall_System_MathF_Pow (float x, float y)
285 return powf (x, y);
288 float
289 ves_icall_System_MathF_Sin (float x)
291 return sinf (x);
294 float
295 ves_icall_System_MathF_Sinh (float x)
297 return sinh (x);
300 float
301 ves_icall_System_MathF_Sqrt (float x)
303 return sqrtf (x);
306 float
307 ves_icall_System_MathF_Tan (float x)
309 return tanf (x);
312 float
313 ves_icall_System_MathF_Tanh (float x)
315 return tanh (x);
318 float
319 ves_icall_System_MathF_FMod (float x, float y)
321 return fmodf (x, y);
324 float
325 ves_icall_System_MathF_ModF (float x, float *d)
327 return modff (x, d);