roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.8k stars 501 forks source link

Fix :formatted_value for `0%`-formatted numeric cells #548

Closed leboshi closed 1 year ago

leboshi commented 4 years ago

Summary

Fixes #547. Possibly related to #384?

Currently, the formatter for 0%-formatted cells (integer percentages) uses %d%%, which truncates input. This exposes floating-point errors in strange ways. Specifically, 57% is stored as 0.56999999999999995, which comes out of the formatter as 56%. Changing the format template to a 0-precision float, %.0f%%, instructs the formatter to round the input instead of truncating.