better-word-count
better-word-count copied to clipboard
Only display rounded statistics
I'm displaying "daily page count" from the calculated statistics. This is just a division (words / constant
) and regularly gives me full decimals for the floating point value. For example today it's displaying 1.8999999999999997
for the current value.
I would expect to have this limited to a more useful number of digits, for example two digits so the above number would be displayed 1.9
or 1.90
. As a human, I don't want to be distracted trying to interpret that number more meaningfully, it's just an estimation tool for me.
I also expect the statistics calculated and stored would have the full accurate number, so this would be more how Better Word Count displays values, not how it stores them.
I don't personally care if I can configure it or not.
I may submit a PR, but to document what I'm seeing in code:
StatusBar.ts#L167 is where the Daily Page Count is pulled in. Lots of other values pulled from statsManager
that could have this same problem.
The display
variable gets built up:
- first from prefix is appended to empty string
- then value is appended, like getDailyPages
- finally the suffix is appended
So either each calculated field should get formatted individually, or we build the display text at the end after we've had a chance to format whatever value we pull out of statsManager.