dandruff / xCT

A light weight scrolling combat text implementation.
53 stars 22 forks source link

Class Power Formatting fights Floating-Point Man and loses #156

Open Farmbuyer opened 5 years ago

Farmbuyer commented 5 years ago

My Frames -> Class Power is enabled, with Misc's three Miscellaneous Settings checkboxes all enabled. And most of the time, everything is fine.

Once in a while, I'll see things like "+35.0000008362 Rage". I know that sometimes, floating-point math can just end up that way, due to binary fractional values being printed in a decimal representation. So this is half a bug report, and half a feature request: please alter frames.lua's Abbreviate routine to not use tostring() to do the number-to-string conversion, but a proper "%.2f if it's not a whole number" format instead.

Note that the "Number Formatting" checkbox for the frame doesn't matter in this case. The fractional number has already been converted to an overly-long string by tostring() before the Number Formatting part of the Abbreviate() routine begins.

combattext.lua's format_energy could also be changed to use "%.2f" (or something similar) but that would require more changes elsewhere through the addon.