Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"@stdlib/napi/argv-double",
"@stdlib/napi/create-double",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/high-word-sign-mask"
"@stdlib/constants/float64/high-word-sign-mask",
"@stdlib/constants/float64/nan"
]
},
{
Expand All @@ -56,7 +57,8 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/high-word-sign-mask"
"@stdlib/constants/float64/high-word-sign-mask",
"@stdlib/constants/float64/nan"
]
},
{
Expand All @@ -72,6 +74,7 @@
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/high-word-sign-mask",
"@stdlib/constants/float64/nan",
"@stdlib/constants/float64/eps",
"@stdlib/constants/float64/smallest-subnormal"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "stdlib/number/float64/base/ulp_difference.h"
#include "stdlib/math/base/assert/is_nan.h"
#include "stdlib/constants/float64/high_word_sign_mask.h"
#include "stdlib/constants/float64/nan.h"
#include <stdint.h>

static const uint64_t SIGN_MASK = (uint64_t)STDLIB_CONSTANT_FLOAT64_HIGH_WORD_SIGN_MASK << 32;
Expand Down Expand Up @@ -50,7 +51,9 @@ static uint64_t monotone_key( const uint64_t word ) {
* // returns 1.0
*
* @example
* double d = stdlib_base_float64_ulp_difference( 0.0 / 0.0, 1.0 );
* #include "stdlib/constants/float64/nan.h"
*
* double d = stdlib_base_float64_ulp_difference( STDLIB_CONSTANT_FLOAT64_NAN, 1.0 );
* // returns NaN
*/
double stdlib_base_float64_ulp_difference( const double x, const double y ) {
Expand All @@ -60,7 +63,7 @@ double stdlib_base_float64_ulp_difference( const double x, const double y ) {
uint64_t wy;

if ( stdlib_base_is_nan( x ) || stdlib_base_is_nan( y ) ) {
return 0.0 / 0.0;
return STDLIB_CONSTANT_FLOAT64_NAN;
}
ux.value = x;
uy.value = y;
Expand Down