diff --git a/lib/node_modules/@stdlib/math/base/special/atan2/lib/main.js b/lib/node_modules/@stdlib/math/base/special/atan2/lib/main.js index 6248f429a6ed..48d6564ccb46 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan2/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2/lib/main.js @@ -159,7 +159,7 @@ function atan2( y, x ) { } q = atan( y / x ); if ( x < 0.0 ) { - if ( q <= 0.0 ) { + if ( y > 0.0 ) { return q + PI; } return q - PI; diff --git a/lib/node_modules/@stdlib/math/base/special/atan2/src/main.c b/lib/node_modules/@stdlib/math/base/special/atan2/src/main.c index 5b742c377182..2e9e51c3ffda 100755 --- a/lib/node_modules/@stdlib/math/base/special/atan2/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/atan2/src/main.c @@ -111,7 +111,7 @@ double stdlib_base_atan2( const double y, const double x ) { } q = stdlib_base_atan( y / x ); if ( x < 0.0 ) { - if ( q <= 0.0 ) { + if ( y > 0.0 ) { return q + STDLIB_CONSTANT_FLOAT64_PI; } return q - STDLIB_CONSTANT_FLOAT64_PI; diff --git a/lib/node_modules/@stdlib/math/base/special/atan2/test/test.js b/lib/node_modules/@stdlib/math/base/special/atan2/test/test.js index b40184637e9a..339a20eff6d1 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan2/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2/test/test.js @@ -233,3 +233,10 @@ tape( 'the function evaluates the `atan2` function (when x and y are negative)', } t.end(); }); + +tape( 'the function returns `-PI` if provided a negative `y` and a negative `x` whose ratio underflows', function test( t ) { + t.strictEqual( atan2( -1.0e-300, -1.0e300 ), -PI, 'returns expected value' ); + t.strictEqual( atan2( -5.0e-324, -1.0 ), -PI, 'returns expected value' ); + t.strictEqual( atan2( 1.0e-300, -1.0e300 ), PI, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/atan2/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/atan2/test/test.native.js index 2f3a3db1f619..24d94274f457 100755 --- a/lib/node_modules/@stdlib/math/base/special/atan2/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2/test/test.native.js @@ -242,3 +242,10 @@ tape( 'the function evaluates the `atan2` function (when x and y are negative)', } t.end(); }); + +tape( 'the function returns `-PI` if provided a negative `y` and a negative `x` whose ratio underflows', opts, function test( t ) { + t.strictEqual( atan2( -1.0e-300, -1.0e300 ), -PI, 'returns expected value' ); + t.strictEqual( atan2( -5.0e-324, -1.0 ), -PI, 'returns expected value' ); + t.strictEqual( atan2( 1.0e-300, -1.0e300 ), PI, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/atan2f/lib/main.js index fcab4e28790f..0be2edc1a175 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/lib/main.js @@ -171,7 +171,7 @@ function atan2f( y, x ) { } q = atanf( f32( y / x ) ); if ( x < 0.0 ) { - if ( q <= 0.0 ) { + if ( y > 0.0 ) { return f32( q + PI ); } return f32( q - PI ); diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/atan2f/src/main.c index 4779f6984091..84c0c31dd5fc 100755 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/src/main.c @@ -103,7 +103,7 @@ float stdlib_base_atan2f( const float y, const float x ) { } q = stdlib_base_atanf( y / x ); if ( x < 0.0f ) { - if ( q <= 0.0f ) { + if ( y > 0.0f ) { return q + STDLIB_CONSTANT_FLOAT32_PI; } return q - STDLIB_CONSTANT_FLOAT32_PI; diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js index 44240997c678..a9eb9a4099aa 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js @@ -237,3 +237,10 @@ tape( 'the function evaluates the `atan2f` function (when x and y are negative)' } t.end(); }); + +tape( 'the function returns `-PI` if provided a negative `y` and a negative `x` whose ratio underflows', function test( t ) { + t.strictEqual( atan2f( -1.0e-30, -1.0e30 ), -PI, 'returns expected value' ); + t.strictEqual( atan2f( -1.0e-45, -1.0 ), -PI, 'returns expected value' ); + t.strictEqual( atan2f( 1.0e-30, -1.0e30 ), PI, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js index 6824aec73f7a..42d787bc9a49 100755 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js @@ -246,3 +246,10 @@ tape( 'the function evaluates the `atan2f` function (when x and y are negative)' } t.end(); }); + +tape( 'the function returns `-PI` if provided a negative `y` and a negative `x` whose ratio underflows', opts, function test( t ) { + t.strictEqual( atan2f( -1.0e-30, -1.0e30 ), -PI, 'returns expected value' ); + t.strictEqual( atan2f( -1.0e-45, -1.0 ), -PI, 'returns expected value' ); + t.strictEqual( atan2f( 1.0e-30, -1.0e30 ), PI, 'returns expected value' ); + t.end(); +});