From 0b6ccb2aab90d77531fcfb34526b4e2c8ccd65f7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 4 Mar 2024 19:17:31 +0530 Subject: [PATCH 1/3] fix: failed C examples in develop --- .../@stdlib/math/base/special/ceiln/examples/c/example.c | 2 +- lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c | 3 ++- .../@stdlib/math/base/special/floorn/examples/c/example.c | 2 +- lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c | 3 ++- .../@stdlib/math/base/special/min/examples/c/example.c | 3 ++- .../@stdlib/math/base/special/minabs/examples/c/example.c | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceiln/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ceiln/examples/c/example.c index 78d6235f25e6..6e1e7d16ad28 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceiln/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ceiln/examples/c/example.c @@ -19,7 +19,7 @@ #include "stdlib/math/base/special/ceiln.h" #include -int main() { +int main( void ) { const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 }; double y; diff --git a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c index f71ee15288f1..5ef896b92b03 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c +++ b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c @@ -32,8 +32,9 @@ // VARIABLES // +#define HUGE 1.0e308 + static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; -static const double HUGE = 1.0e+308; // MAIN // diff --git a/lib/node_modules/@stdlib/math/base/special/floorn/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/floorn/examples/c/example.c index 872bcefa56db..e3dec0287100 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorn/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/floorn/examples/c/example.c @@ -19,7 +19,7 @@ #include "stdlib/math/base/special/floorn.h" #include -int main() { +int main( void ) { const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 }; double y; diff --git a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c index a6586a28b73c..5eb2ad1cd2ef 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c +++ b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c @@ -32,8 +32,9 @@ // VARIABLES // +#define HUGE 1.0e308 + static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; -static const double HUGE = 1.0e+308; // MAIN // diff --git a/lib/node_modules/@stdlib/math/base/special/min/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/min/examples/c/example.c index da9ef64a7120..f94c1e3bf307 100644 --- a/lib/node_modules/@stdlib/math/base/special/min/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/min/examples/c/example.c @@ -17,6 +17,7 @@ */ #include "stdlib/math/base/special/min.h" +#include #include int main( void ) { @@ -31,4 +32,4 @@ int main( void ) { v = stdlib_base_min( x, y ); printf( "x: %lf, y: %lf, min(x, y): %lf\n", x, y, v ); } -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/math/base/special/minabs/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/minabs/examples/c/example.c index 4cc8892bbde6..384eb481b3ed 100644 --- a/lib/node_modules/@stdlib/math/base/special/minabs/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/minabs/examples/c/example.c @@ -17,6 +17,7 @@ */ #include "stdlib/math/base/special/minabs.h" +#include #include int main( void ) { @@ -31,4 +32,4 @@ int main( void ) { v = stdlib_base_minabs( x, y ); printf( "x: %lf, y: %lf, minabs(x, y): %lf\n", x, y, v ); } -} \ No newline at end of file +} From 216c5007552afea1f5b19e200ca15bfa9d401dae Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 5 Mar 2024 17:10:45 +0530 Subject: [PATCH 2/3] chore: minor-fix --- .../@stdlib/math/base/special/ceiln/src/ceiln.c | 7 +++---- .../@stdlib/math/base/special/floorn/src/floorn.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c index 5ef896b92b03..3d852fdff699 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c +++ b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c @@ -32,9 +32,8 @@ // VARIABLES // -#define HUGE 1.0e308 - static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; +static const double HUGE_VALUE = 1.0e308; // MAIN // @@ -92,11 +91,11 @@ double stdlib_base_ceiln( const double x, const int32_t n ) { // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... if ( n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) { s = pow( 10.0, -( n + STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent - y = ( x * HUGE ) * s; // order of operation matters! + y = ( x * HUGE_VALUE ) * s; // order of operation matters! if ( stdlib_base_is_infinite( y ) ) { return x; } - return ( stdlib_base_ceil( y ) / HUGE ) / s; + return ( stdlib_base_ceil( y ) / HUGE_VALUE ) / s; } s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent y = x * s; diff --git a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c index 5eb2ad1cd2ef..9578d6d283bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c +++ b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c @@ -32,9 +32,8 @@ // VARIABLES // -#define HUGE 1.0e308 - static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; +static const double HUGE_VALUE = 1.0e308; // MAIN // @@ -135,11 +134,11 @@ double stdlib_base_floorn( const double x, const int32_t n ) { // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... if ( n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) { s = pow( 10.0, - ( n + STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent - y = ( x * HUGE ) * s; // order of operation matters! + y = ( x * HUGE_VALUE ) * s; // order of operation matters! if ( stdlib_base_is_infinite( y ) ) { return x; } - return ( stdlib_base_floor( y ) / HUGE ) / s; + return ( stdlib_base_floor( y ) / HUGE_VALUE ) / s; } s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent y = x * s; From 91878eb4846ee9fc90f2b7785f2dcea72aa9fcd2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 5 Mar 2024 17:13:01 +0530 Subject: [PATCH 3/3] chore: rectify value --- lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c | 2 +- lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c index 3d852fdff699..86f991ebb4e9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c +++ b/lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c @@ -33,7 +33,7 @@ // VARIABLES // static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; -static const double HUGE_VALUE = 1.0e308; +static const double HUGE_VALUE = 1.0e+308; // MAIN // diff --git a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c index 9578d6d283bb..9f21b6044695 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c +++ b/lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c @@ -33,7 +33,7 @@ // VARIABLES // static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0; -static const double HUGE_VALUE = 1.0e308; +static const double HUGE_VALUE = 1.0e+308; // MAIN //