For example:
I'm looking for a way to shorten very large numbers into a nice to read format.
number_to_human is very close to what you're asking for. It rounds up and down, so 410589 would become "411 K", not sure if that's ok.
You'll need either some I18n mappings, or provide a hash of units to get your suffixes, and a little tweaking to get the precision you want, but for example:
opts = { units: { thousand: "K" }, precision: 0, significant: false }
number_to_human 410589, opts # => "411 K"
number_to_human 4509, opts # => "5 K"
number_to_human 349, opts # => "349"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With