From 8c8946e55d662fb4dfad3fe9a422983c9bdafe21 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Thu, 8 Aug 2024 07:19:23 +0530 Subject: [PATCH 1/3] docs: use `float` instead of `double` Signed-off-by: Gunj Joshi --- .../base/special/truncf/benchmark/c/native/benchmark.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/native/benchmark.c index 42b5cae36d15..43e484efa6cf 100644 --- a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/native/benchmark.c @@ -79,9 +79,9 @@ static double tic( void ) { * * @return random number */ -static double rand_double( void ) { +static float rand_float( void ) { int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); + return (float)r / ( (float)RAND_MAX + 1.0f ); } /** @@ -91,14 +91,14 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; double t; + float x; + float y; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; + x = ( 1000.0f * rand_float() ) - 500.0f; y = stdlib_base_truncf( x ); if ( y != y ) { printf( "should not return NaN\n" ); From 607e08b40edcb70b66e06e47daaa6e1b573b783e Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Thu, 8 Aug 2024 07:22:08 +0530 Subject: [PATCH 2/3] docs: use `float` instead of `double` Signed-off-by: Gunj Joshi --- .../math/base/special/truncf/benchmark/c/benchmark.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c index 4f8fd799d477..ed803dd8e0f0 100644 --- a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c @@ -78,9 +78,9 @@ static double tic( void ) { * * @return random number */ -static double rand_double( void ) { +static float rand_double( void ) { int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); + return (float)r / ( (float)RAND_MAX + 1.0f ); } /** @@ -90,14 +90,14 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; double t; + float x; + float y; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; + x = ( 1000.0f * rand_double() ) - 500.0f; y = truncf( x ); if ( y != y ) { printf( "should not return NaN\n" ); From f2a0e8f916d07a7caf9501469dfb6cc3726975a3 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 8 Aug 2024 00:18:35 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/math/base/special/truncf/benchmark/c/benchmark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c index ed803dd8e0f0..246f021e6c39 100644 --- a/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c/benchmark.c @@ -78,7 +78,7 @@ static double tic( void ) { * * @return random number */ -static float rand_double( void ) { +static float rand_float( void ) { int r = rand(); return (float)r / ( (float)RAND_MAX + 1.0f ); } @@ -97,7 +97,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0f * rand_double() ) - 500.0f; + x = ( 1000.0f * rand_float() ) - 500.0f; y = truncf( x ); if ( y != y ) { printf( "should not return NaN\n" );