3 * these are based on bob smith's csharp routines
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.
20 // - src/classlibnative/float/floatnative.cpp
21 // - src/pal/src/cruntime/floatnative.cpp
23 // Ported from C++ to C and adjusted to Mono runtime
29 #include "number-ms.h"
30 #include "utils/mono-compiler.h"
32 #include "icall-decl.h"
35 ves_icall_System_Math_Floor (gdouble x
)
41 ves_icall_System_Math_Round (gdouble x
)
45 /* If the number has no fractional part do nothing This shortcut is necessary
46 * to workaround precision loss in borderline cases on some platforms */
47 if (x
== (gdouble
)(gint64
) x
)
50 floor_tmp
= floor (x
+ 0.5);
52 if ((x
== (floor (x
) + 0.5)) && (fmod (floor_tmp
, 2.0) != 0)) {
56 return copysign (floor_tmp
, x
);
60 ves_icall_System_Math_FMod (gdouble x
, gdouble y
)
66 ves_icall_System_Math_ModF (gdouble x
, gdouble
*d
)
72 ves_icall_System_Math_Sin (gdouble x
)
78 ves_icall_System_Math_Cos (gdouble x
)
84 ves_icall_System_Math_Cbrt (gdouble x
)
90 ves_icall_System_Math_Tan (gdouble x
)
96 ves_icall_System_Math_Sinh (gdouble x
)
102 ves_icall_System_Math_Cosh (gdouble x
)
108 ves_icall_System_Math_Tanh (gdouble x
)
114 ves_icall_System_Math_Acos (gdouble x
)
120 ves_icall_System_Math_Acosh (gdouble x
)
126 ves_icall_System_Math_Asin (gdouble x
)
132 ves_icall_System_Math_Asinh (gdouble x
)
138 ves_icall_System_Math_Atan (gdouble x
)
144 ves_icall_System_Math_Atan2 (gdouble y
, gdouble x
)
150 ves_icall_System_Math_Atanh (gdouble x
)
156 ves_icall_System_Math_Exp (gdouble x
)
162 ves_icall_System_Math_Log (gdouble x
)
168 ves_icall_System_Math_Log10 (gdouble x
)
174 ves_icall_System_Math_Pow (gdouble x
, gdouble y
)
180 ves_icall_System_Math_Sqrt (gdouble x
)
186 ves_icall_System_Math_Abs_double (gdouble v
)
192 ves_icall_System_Math_Abs_single (float v
)
198 ves_icall_System_Math_Ceiling (gdouble v
)
204 ves_icall_System_MathF_Acos (float x
)
210 ves_icall_System_MathF_Acosh (float x
)
216 ves_icall_System_MathF_Asin (float x
)
222 ves_icall_System_MathF_Asinh (float x
)
228 ves_icall_System_MathF_Atan (float x
)
234 ves_icall_System_MathF_Atan2 (float x
, float y
)
236 return atan2f (x
, y
);
240 ves_icall_System_MathF_Atanh (float x
)
246 ves_icall_System_MathF_Cbrt (float x
)
252 ves_icall_System_MathF_Ceiling (float x
)
258 ves_icall_System_MathF_Cos (float x
)
264 ves_icall_System_MathF_Cosh (float x
)
270 ves_icall_System_MathF_Exp (float x
)
276 ves_icall_System_MathF_Floor (float x
)
282 ves_icall_System_MathF_Log (float x
)
288 ves_icall_System_MathF_Log10 (float x
)
294 ves_icall_System_MathF_Pow (float x
, float y
)
300 ves_icall_System_MathF_Sin (float x
)
306 ves_icall_System_MathF_Sinh (float x
)
312 ves_icall_System_MathF_Sqrt (float x
)
318 ves_icall_System_MathF_Tan (float x
)
324 ves_icall_System_MathF_Tanh (float x
)
330 ves_icall_System_MathF_FMod (float x
, float y
)
336 ves_icall_System_MathF_ModF (float x
, float *d
)