Skip to content

Commit c884ee3

Browse files
authored
refactor: precompute constant
Signed-off-by: Athan <[email protected]>
1 parent d68c4d0 commit c884ee3

File tree

1 file changed

+2
-1
lines changed
  • lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src

1 file changed

+2
-1
lines changed

lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdbool.h>
2727

2828
static const float SQRT_5 = 2.23606797749979f;
29+
static const float LN_PHI = stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI );
2930

3031
/**
3132
* Computes the Fibonacci number index of a single-precision floating-point number.
@@ -48,5 +49,5 @@ float stdlib_base_fibonacci_indexf( const float F ) {
4849
return 0.0f / 0.0f; // NaN
4950
}
5051
x = ( F * SQRT_5 ) + 0.5f;
51-
return stdlib_base_roundf( stdlib_base_lnf( x ) / stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ) );
52+
return stdlib_base_roundf( stdlib_base_lnf( x ) / LN_PHI );
5253
}

0 commit comments

Comments
 (0)