FastLog2 constant improvement #110

Closed
opened 2026-01-29 20:35:20 +00:00 by claunia · 3 comments
Owner

Originally created by @mikir on GitHub (May 25, 2016).

In the header fast_log.h, the following constant is used:

static const double kLog2Inv = 1.4426950408889634f;

Please, consider to replace this constant with exact formula not to loose accuracy:

static const double kLog2Inv = 1.0f / log(2);

Originally created by @mikir on GitHub (May 25, 2016). In the header fast_log.h, the following constant is used: `static const double kLog2Inv = 1.4426950408889634f;` Please, consider to replace this constant with exact formula not to loose accuracy: `static const double kLog2Inv = 1.0f / log(2);`
Author
Owner

@eustas commented on GitHub (May 31, 2016):

Constant already has too high prescision.
When either of kLog2Inv values is printed out the result is 1.4426950_2162933349609_

@eustas commented on GitHub (May 31, 2016): Constant already has too high prescision. When either of kLog2Inv values is printed out the result is 1.4426950_2162933349609_
Author
Owner

@jyrkialakuijala commented on GitHub (May 31, 2016):

perhaps removing the f from the end would change something on another compiler?

@jyrkialakuijala commented on GitHub (May 31, 2016): perhaps removing the f from the end would change something on another compiler?
Author
Owner

@eustas commented on GitHub (Jun 16, 2016):

Fixed in v0.5
NB: most frequently used values are looked up in table. High precision for bigger values is not required.

@eustas commented on GitHub (Jun 16, 2016): Fixed in v0.5 NB: most frequently used values are looked up in table. High precision for bigger values is not required.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#110