Module | Numeric::Multipliers |
In: |
lib/more/facets/multipliers.rb
|
Adds methods to Numeric to make working with magnitudes (kilo, mega, giga, milli, micro, etc.)
1.kilo #=> 1000 1.milli #=> 0.001 1.kibi #=> 1024
To display a value in a certain denomination, simply perform the inverse operation by placing the multiplier called on unit (1) in the denominator.
(1000 / 1.kilo) #=> 1 (1024 / 1.kibi) #=> 1
Thanks to Rich Kilmer and bytes.rb which inspired this library.