diff --git a/lib/node_modules/@stdlib/math/base/special/atanf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/atanf/lib/main.js index f38947693d1b..49bc11ab4480 100644 --- a/lib/node_modules/@stdlib/math/base/special/atanf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/atanf/lib/main.js @@ -86,8 +86,8 @@ function atanf( x ) { var y; var z; - if ( isnanf( x ) ) { - return NaN; + if ( isnanf( x ) || x === 0.0 ) { + return x; } x = float64ToFloat32( x ); if ( x < 0.0 ) { diff --git a/lib/node_modules/@stdlib/math/base/special/atanf/src/main.c b/lib/node_modules/@stdlib/math/base/special/atanf/src/main.c index 71d47b99bf64..507a8f4c4336 100644 --- a/lib/node_modules/@stdlib/math/base/special/atanf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/atanf/src/main.c @@ -88,8 +88,8 @@ float stdlib_base_atanf( const float x ) { float y; float z; - if ( stdlib_base_is_nanf( x ) ) { - return 0.0f / 0.0f; // NaN + if ( stdlib_base_is_nanf( x ) || x == 0.0f ) { + return x; } ax = x; if ( x < 0.0f ) { diff --git a/lib/node_modules/@stdlib/math/base/special/atanf/test/test.js b/lib/node_modules/@stdlib/math/base/special/atanf/test/test.js index 452e99843d89..38a76e7c4e60 100644 --- a/lib/node_modules/@stdlib/math/base/special/atanf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/atanf/test/test.js @@ -25,6 +25,8 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float32/eps' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); var atanf = require( './../lib' ); @@ -396,3 +398,21 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { t.equal( isnanf( v ), true, 'returns NaN' ); t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v = atanf( -0.0 ); + t.equal( isNegativeZerof( v ), true, 'returns -0' ); + t.end(); +}); + +tape( 'the function returns `0` if provided +0', function test( t ) { + var v; + + v = atanf( 0.0 ); + t.equal( isPositiveZerof( v ), true, 'returns +0' ); + + v = atanf( +0.0 ); + t.equal( isPositiveZerof( v ), true, 'returns +0' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/atanf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/atanf/test/test.native.js index bd6dd423738f..c05a44387bcc 100644 --- a/lib/node_modules/@stdlib/math/base/special/atanf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/atanf/test/test.native.js @@ -26,6 +26,8 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float32/eps' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -405,3 +407,21 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { t.equal( isnanf( v ), true, 'returns NaN' ); t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v = atanf( -0.0 ); + t.equal( isNegativeZerof( v ), true, 'returns -0' ); + t.end(); +}); + +tape( 'the function returns `0` if provided +0', opts, function test( t ) { + var v; + + v = atanf( 0.0 ); + t.equal( isPositiveZerof( v ), true, 'returns +0' ); + + v = atanf( +0.0 ); + t.equal( isPositiveZerof( v ), true, 'returns +0' ); + + t.end(); +});