Skip to content

Commit 2f2788c

Browse files
PranavchikuUtkarsh Gupta
authored and
Utkarsh Gupta
committed
docs: fix errors in various C examples
PR-URL: stdlib-js#1691 Reviewed-by: Athan Reines <[email protected]>
1 parent 3f0ccb8 commit 2f2788c

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

lib/node_modules/@stdlib/math/base/special/ceiln/examples/c/example.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "stdlib/math/base/special/ceiln.h"
2020
#include <stdio.h>
2121

22-
int main() {
22+
int main( void ) {
2323
const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
2424

2525
double y;

lib/node_modules/@stdlib/math/base/special/ceiln/src/ceiln.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// VARIABLES //
3434

3535
static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0;
36-
static const double HUGE = 1.0e+308;
36+
static const double HUGE_VALUE = 1.0e+308;
3737

3838

3939
// MAIN //
@@ -91,11 +91,11 @@ double stdlib_base_ceiln( const double x, const int32_t n ) {
9191
// 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...
9292
if ( n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) {
9393
s = pow( 10.0, -( n + STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent
94-
y = ( x * HUGE ) * s; // order of operation matters!
94+
y = ( x * HUGE_VALUE ) * s; // order of operation matters!
9595
if ( stdlib_base_is_infinite( y ) ) {
9696
return x;
9797
}
98-
return ( stdlib_base_ceil( y ) / HUGE ) / s;
98+
return ( stdlib_base_ceil( y ) / HUGE_VALUE ) / s;
9999
}
100100
s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent
101101
y = x * s;

lib/node_modules/@stdlib/math/base/special/floorn/examples/c/example.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "stdlib/math/base/special/floorn.h"
2020
#include <stdio.h>
2121

22-
int main() {
22+
int main( void ) {
2323
const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
2424

2525
double y;

lib/node_modules/@stdlib/math/base/special/floorn/src/floorn.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// VARIABLES //
3434

3535
static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0;
36-
static const double HUGE = 1.0e+308;
36+
static const double HUGE_VALUE = 1.0e+308;
3737

3838

3939
// MAIN //
@@ -134,11 +134,11 @@ double stdlib_base_floorn( const double x, const int32_t n ) {
134134
// 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...
135135
if ( n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) {
136136
s = pow( 10.0, - ( n + STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent
137-
y = ( x * HUGE ) * s; // order of operation matters!
137+
y = ( x * HUGE_VALUE ) * s; // order of operation matters!
138138
if ( stdlib_base_is_infinite( y ) ) {
139139
return x;
140140
}
141-
return ( stdlib_base_floor( y ) / HUGE ) / s;
141+
return ( stdlib_base_floor( y ) / HUGE_VALUE ) / s;
142142
}
143143
s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent
144144
y = x * s;

lib/node_modules/@stdlib/math/base/special/min/examples/c/example.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/min.h"
20+
#include <stdlib.h>
2021
#include <stdio.h>
2122

2223
int main( void ) {
@@ -31,4 +32,4 @@ int main( void ) {
3132
v = stdlib_base_min( x, y );
3233
printf( "x: %lf, y: %lf, min(x, y): %lf\n", x, y, v );
3334
}
34-
}
35+
}

lib/node_modules/@stdlib/math/base/special/minabs/examples/c/example.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/minabs.h"
20+
#include <stdlib.h>
2021
#include <stdio.h>
2122

2223
int main( void ) {
@@ -31,4 +32,4 @@ int main( void ) {
3132
v = stdlib_base_minabs( x, y );
3233
printf( "x: %lf, y: %lf, minabs(x, y): %lf\n", x, y, v );
3334
}
34-
}
35+
}

0 commit comments

Comments
 (0)