Enforcing rational-based conversions between custom-unit-based quantities in Boost.Units

I have a custom unit system defined, which derives from boost::units::si::time. Child units are defined using boost::units::make_scaled_unit, hence the conversion factors are specified using boost::units::scale and boost::units::static_rational, e.g. boost::units::scale<1020, boost::units::static_rational<1> >.

In general I would not complain, if it wasn't for the boost::units::scale::value_type being 'double'. As a result all runtime conversions between quantities involve floating point arithmetics, whereas the ratios between my custom units are all integers, e.g. 1 apple equals 18 oranges, and conversions using rational-based factors would suffice.

Is there a way to override the floating point arithmetics used for units convesion with something else? Thanks.

EDIT: 1. my quantities are defined using integer types.

Upvotes: 2

Views: 129

Answers (0)

Related Questions