Skip to content

Commit a85fb1e

Browse files
committed
"converted floating point value to a word"
1 parent 0815ad7 commit a85fb1e

File tree

1 file changed

+11
-7
lines changed
  • lib/node_modules/@stdlib/math/base/special/atanh/src

1 file changed

+11
-7
lines changed

lib/node_modules/@stdlib/math/base/special/atanh/src/main.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,24 @@ static const double NEAR_ZERO = 1.0 / (1 << 28); // 2**-28
7878
* out = stdlib_base_atanh( 0.9 );
7979
* // returns ~1.472
8080
*/
81+
82+
static const double one = 1.0;
83+
static const double zero = 0.0;
84+
8185
double stdlib_base_atanh( const double x ) {
8286
int32_t sgn;
8387
double ax;
8488
double t;
85-
if ( stdlib_base_is_nan( x ) || x < -1.0 || x > 1.0 ) {
86-
return 0.0 / 0.0; // NaN
89+
if ( stdlib_base_is_nan( x ) || x < -one || x > one ) {
90+
return zero / zero ; // NaN
8791
}
88-
if ( x == 1.0 ) {
92+
if ( x === one ) {
8993
return STDLIB_CONSTANT_FLOAT64_PINF;
9094
}
91-
if ( x == -1.0 ) {
95+
if ( x == -one ) {
9296
return STDLIB_CONSTANT_FLOAT64_NINF;
9397
}
94-
if ( x < 0.0 ) {
98+
if ( x < zero ) {
9599
sgn = 1;
96100
ax = -x;
97101
} else {
@@ -104,9 +108,9 @@ double stdlib_base_atanh( const double x ) {
104108
}
105109
if ( ax < 0.5 ) {
106110
t = ax + ax;
107-
t = 0.5 * stdlib_base_log1p( t + ( t * ax / ( 1 - ax ) ) );
111+
t = 0.5 * stdlib_base_log1p( t + ( t * ax / ( one - ax ) ) );
108112
} else {
109-
t = 0.5 * stdlib_base_log1p( ( ax + ax ) / ( 1 - ax ) );
113+
t = 0.5 * stdlib_base_log1p( ( ax + ax ) / ( one - ax ) );
110114
}
111115
return ( sgn == 1 ) ? -t : t;
112116
}

0 commit comments

Comments
 (0)