summaryrefslogtreecommitdiff
path: root/src/classlibnative/float/floatsingle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/classlibnative/float/floatsingle.cpp')
-rw-r--r--src/classlibnative/float/floatsingle.cpp69
1 files changed, 19 insertions, 50 deletions
diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp
index 7e2ea0adc6..c7b7d4126b 100644
--- a/src/classlibnative/float/floatsingle.cpp
+++ b/src/classlibnative/float/floatsingle.cpp
@@ -9,18 +9,12 @@
#include "floatsingle.h"
-#define IS_FLT_INFINITY(x) (((*((INT32*)((void*)&x))) & 0x7FFFFFFF) == 0x7F800000)
-
// Windows x86 and Windows ARM/ARM64 may not define _isnanf() or _copysignf() but they do
// define _isnan() and _copysign(). We will redirect the macros to these other functions if
// the macro is not defined for the platform. This has the side effect of a possible implicit
// upcasting for arguments passed in and an explicit downcasting for the _copysign() call.
#if (defined(_TARGET_X86_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)) && !defined(FEATURE_PAL)
-#if !defined(_isnanf)
-#define _isnanf _isnan
-#endif
-
#if !defined(_copysignf)
#define _copysignf (float)_copysign
#endif
@@ -49,7 +43,7 @@
/*=====================================Abs=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Abs, float x)
+FCIMPL1_V(float, COMSingle::Abs, float x)
FCALL_CONTRACT;
return (float)fabsf(x);
@@ -58,7 +52,7 @@ FCIMPLEND
/*=====================================Acos=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Acos, float x)
+FCIMPL1_V(float, COMSingle::Acos, float x)
FCALL_CONTRACT;
return (float)acosf(x);
@@ -67,7 +61,7 @@ FCIMPLEND
/*=====================================Asin=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Asin, float x)
+FCIMPL1_V(float, COMSingle::Asin, float x)
FCALL_CONTRACT;
return (float)asinf(x);
@@ -76,7 +70,7 @@ FCIMPLEND
/*=====================================Atan=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Atan, float x)
+FCIMPL1_V(float, COMSingle::Atan, float x)
FCALL_CONTRACT;
return (float)atanf(x);
@@ -85,23 +79,16 @@ FCIMPLEND
/*=====================================Atan2====================================
**
==============================================================================*/
-FCIMPL2(float, COMSingle::Atan2, float y, float x)
+FCIMPL2_VV(float, COMSingle::Atan2, float y, float x)
FCALL_CONTRACT;
- // atan2f(+/-INFINITY, +/-INFINITY) produces +/-0.785398163f (x is +INFINITY) and
- // +/-2.35619449f (x is -INFINITY) instead of the expected value of NaN. We handle
- // that case here ourselves.
- if (IS_FLT_INFINITY(y) && IS_FLT_INFINITY(x)) {
- return (float)(y / x);
- }
-
return (float)atan2f(y, x);
FCIMPLEND
/*====================================Ceil======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Ceil, float x)
+FCIMPL1_V(float, COMSingle::Ceil, float x)
FCALL_CONTRACT;
return (float)ceilf(x);
@@ -110,7 +97,7 @@ FCIMPLEND
/*=====================================Cos======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Cos, float x)
+FCIMPL1_V(float, COMSingle::Cos, float x)
FCALL_CONTRACT;
return (float)cosf(x);
@@ -119,7 +106,7 @@ FCIMPLEND
/*=====================================Cosh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Cosh, float x)
+FCIMPL1_V(float, COMSingle::Cosh, float x)
FCALL_CONTRACT;
return (float)coshf(x);
@@ -128,7 +115,7 @@ FCIMPLEND
/*=====================================Exp======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Exp, float x)
+FCIMPL1_V(float, COMSingle::Exp, float x)
FCALL_CONTRACT;
return (float)expf(x);
@@ -137,7 +124,7 @@ FCIMPLEND
/*====================================Floor=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Floor, float x)
+FCIMPL1_V(float, COMSingle::Floor, float x)
FCALL_CONTRACT;
return (float)floorf(x);
@@ -146,7 +133,7 @@ FCIMPLEND
/*=====================================Log======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Log, float x)
+FCIMPL1_V(float, COMSingle::Log, float x)
FCALL_CONTRACT;
return (float)logf(x);
@@ -155,7 +142,7 @@ FCIMPLEND
/*====================================Log10=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Log10, float x)
+FCIMPL1_V(float, COMSingle::Log10, float x)
FCALL_CONTRACT;
return (float)log10f(x);
@@ -173,34 +160,16 @@ FCIMPLEND
/*=====================================Pow======================================
**
==============================================================================*/
-FCIMPL2(float, COMSingle::Pow, float x, float y)
+FCIMPL2_VV(float, COMSingle::Pow, float x, float y)
FCALL_CONTRACT;
- // The CRT version of pow preserves the NaN payload of x over the NaN payload of y.
-
- if(_isnanf(y)) {
- return y; // IEEE 754-2008: NaN payload must be preserved
- }
-
- if(_isnanf(x)) {
- return x; // IEEE 754-2008: NaN payload must be preserved
- }
-
- // The CRT version of powf does not return NaN for powf(-1.0f, +/-INFINITY) and
- // instead returns +1.0f.
-
- if(IS_FLT_INFINITY(y) && (x == -1.0f)) {
- INT32 result = CLR_NAN_32;
- return (*((float*)((INT32*)&result)));
- }
-
return (float)powf(x, y);
FCIMPLEND
/*====================================Round=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Round, float x)
+FCIMPL1_V(float, COMSingle::Round, float x)
FCALL_CONTRACT;
// If the number has no fractional part do nothing
@@ -225,7 +194,7 @@ FCIMPLEND
/*=====================================Sin======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sin, float x)
+FCIMPL1_V(float, COMSingle::Sin, float x)
FCALL_CONTRACT;
return (float)sinf(x);
@@ -234,7 +203,7 @@ FCIMPLEND
/*=====================================Sinh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sinh, float x)
+FCIMPL1_V(float, COMSingle::Sinh, float x)
FCALL_CONTRACT;
return (float)sinhf(x);
@@ -243,7 +212,7 @@ FCIMPLEND
/*=====================================Sqrt=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sqrt, float x)
+FCIMPL1_V(float, COMSingle::Sqrt, float x)
FCALL_CONTRACT;
return (float)sqrtf(x);
@@ -252,7 +221,7 @@ FCIMPLEND
/*=====================================Tan======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Tan, float x)
+FCIMPL1_V(float, COMSingle::Tan, float x)
FCALL_CONTRACT;
return (float)tanf(x);
@@ -261,7 +230,7 @@ FCIMPLEND
/*=====================================Tanh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Tanh, float x)
+FCIMPL1_V(float, COMSingle::Tanh, float x)
FCALL_CONTRACT;
return (float)tanhf(x);