Shopify / measured

Encapsulate measurements and their units in Ruby and Ruby on Rails.
MIT License
337 stars 28 forks source link

Use Rational where appropriate #64

Closed thegedge closed 7 years ago

thegedge commented 7 years ago

See https://github.com/Shopify/measured/issues/63 for more context. tl;dr Rational is faster for arithmetic and can represent values that BigDecimal cannot, but slower for parsing decimal numbers. Since the construction of units and the conversion table is a one-off operation, Rational is the best for representing things, especially since conversions are arithmetic operations.

Mostly takes care of https://github.com/Shopify/measured/issues/63, but I have some other changes that I want to make that'll fully close it.