Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
  • Loading branch information
Pranavchiku authored Mar 6, 2024
1 parent dc44d62 commit 63a9a5a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ double benchmark() {

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = rand_double();
x = ( 1000.0*rand_double() ) - 0.0;
y = stdlib_base_log2( x );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Evaluate the binary logarithm.
* Evaluates the binary logarithm.
*
* @private
* @param {number} x - input value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
16 changes: 8 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/log2/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ static double polyval_q( const double x ) {
* @return output value
*/
double klog( const double x ) {
double hfsq;
uint32_t hx;
int32_t i;
int32_t j;
double hfsq;
double t1;
double t2;
double f;
double R;
double s;
double z;
double R;
double w;

stdlib_base_float64_get_high_word( x, &hx );
Expand Down Expand Up @@ -178,11 +178,11 @@ double klog( const double x ) {
double stdlib_base_log2( const double x ) {
uint32_t hx;
uint32_t lx;
double hi;
int32_t i;
int32_t k;
double xc;
double hi;
double lo;
double xc;
double f;

xc = x;
Expand All @@ -196,7 +196,7 @@ double stdlib_base_log2( const double x ) {
if ( ( ( hx & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ) | lx ) == 0 ) {
return STDLIB_CONSTANT_FLOAT64_NINF;
}
k -= 54; // asm type annotation
k -= 54;

// Subnormal number, scale up x:
xc *= TWO54;
Expand All @@ -205,13 +205,13 @@ double stdlib_base_log2( const double x ) {
if ( hx >= HIGH_MAX_NORMAL_EXP ) {
return xc + xc;
}
k += ( ( hx>>20 ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); // asm type annotation
k += ( ( hx>>20 ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS );
hx &= HIGH_SIGNIFICAND_MASK;
i = ( ( hx + 0x95f64 ) & 0x100000 ); // asm type annotation
i = ( ( hx + 0x95f64 ) & 0x100000 );

// Normalize x or x/2...
stdlib_base_float64_set_high_word( hx|( i^HIGH_BIASED_EXP_0 ), &xc );
k += (i>>20); // asm type annotation
k += (i>>20);
f = klog( xc );
xc -= 1;
stdlib_base_float64_set_low_word( xc, &hi );
Expand Down

0 comments on commit 63a9a5a

Please sign in to comment.