File tree 2 files changed +10
-10
lines changed
lib/node_modules/@stdlib/math/base/special/truncf/benchmark/c
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,9 @@ static double tic( void ) {
78
78
*
79
79
* @return random number
80
80
*/
81
- static double rand_double ( void ) {
81
+ static float rand_float ( void ) {
82
82
int r = rand ();
83
- return (double )r / ( (double )RAND_MAX + 1.0 );
83
+ return (float )r / ( (float )RAND_MAX + 1.0f );
84
84
}
85
85
86
86
/**
@@ -90,14 +90,14 @@ static double rand_double( void ) {
90
90
*/
91
91
static double benchmark ( void ) {
92
92
double elapsed ;
93
- double x ;
94
- double y ;
95
93
double t ;
94
+ float x ;
95
+ float y ;
96
96
int i ;
97
97
98
98
t = tic ();
99
99
for ( i = 0 ; i < ITERATIONS ; i ++ ) {
100
- x = ( 1000.0 * rand_double () ) - 500.0 ;
100
+ x = ( 1000.0f * rand_float () ) - 500.0f ;
101
101
y = truncf ( x );
102
102
if ( y != y ) {
103
103
printf ( "should not return NaN\n" );
Original file line number Diff line number Diff line change @@ -79,9 +79,9 @@ static double tic( void ) {
79
79
*
80
80
* @return random number
81
81
*/
82
- static double rand_double ( void ) {
82
+ static float rand_float ( void ) {
83
83
int r = rand ();
84
- return (double )r / ( (double )RAND_MAX + 1.0 );
84
+ return (float )r / ( (float )RAND_MAX + 1.0f );
85
85
}
86
86
87
87
/**
@@ -91,14 +91,14 @@ static double rand_double( void ) {
91
91
*/
92
92
static double benchmark ( void ) {
93
93
double elapsed ;
94
- double x ;
95
- double y ;
96
94
double t ;
95
+ float x ;
96
+ float y ;
97
97
int i ;
98
98
99
99
t = tic ();
100
100
for ( i = 0 ; i < ITERATIONS ; i ++ ) {
101
- x = ( 1000.0 * rand_double () ) - 500.0 ;
101
+ x = ( 1000.0f * rand_float () ) - 500.0f ;
102
102
y = stdlib_base_truncf ( x );
103
103
if ( y != y ) {
104
104
printf ( "should not return NaN\n" );
You can’t perform that action at this time.
0 commit comments