fast_float icon indicating copy to clipboard operation
fast_float copied to clipboard

Add optimized (smaller) lookup table for float type parsing

Open jrahlf opened this issue 4 years ago • 2 comments

Reduce code size if only float accuracy is needed for parsing, implements #99

Pro:

  • reduces binary code size if only float type is used for parsing (numbers are discussed in #99)

Con:

  • minimal binary code size increase if both double and float types are used for parsing
  • increases code bloat

The correct LUT is selected in compute_product_approximation, depending on the bit_precision. Currently it selects the float LUT, if the bit_precision is smaller than 27. I actually do not like this switch, do you have a better proposal?

Adds:

  • script/table_generation_float.py
  • tests/example_test_float.cpp
  • tests/example_test_mixed.cpp

jrahlf avatar Sep 12 '21 13:09 jrahlf

Since one goal is to eventually move this library toward supporting from_chars fully, I am not sure I like the idea of sacrificing the general case for what I see as a rather specific use case (you want to use from_chars but you also only care about binary32).

Certainly, anything that increases the binary bloat of the general case does not move us in the right direction, I think. The idea of better supporting the isolated use case (from_chars but only with binary32) is nice, but I think it should come with no compromise over the general case.

Cheers!

lemire avatar Sep 12 '21 21:09 lemire