Fix fractional numbers in cvt to readable #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've made a fix to the function 'cvt_to_readable' so that it displays fractional values correctly. Before the fix, when the value of 'index' was negative in the case of a small fractional number, for example 0.000001, the suffixes 'K', 'M', 'B', etc. would still be added. With this modification, suffixes such as 'e-003' are added for fractional numbers less than 1.0. Also fixed case where 'index' would result in a value greater than the one corresponding to 'T'.
There was also a spacing inconsistency, for example both '1.24 K' and '12.35K' would be generated for values 1234 and 12345. This was fixed by changing the default format from "5.2f" to ".2f".
The test program has been updated to test for the changes being submitted. Please review and accept this pull request if you wish. I really like termgraph. It's a great command-line utility. Thanks.