nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
961 stars 137 forks source link

int overflow problems? #149

Closed rsivek closed 6 years ago

rsivek commented 6 years ago

When I suggested a new unit for mmHg, @johelegp suggested using the LL suffix to avoid int overflow. I have since noticed a couple of other units which are defined with pretty large ratios which would probably overflow an int such as lightyear and foot_pound. Should those be modified to use the LL suffix as well to avoid overflow problems?

JohelEGP commented 6 years ago

It seems like that was unnecessary. See "The type of the literal" at https://en.cppreference.com/w/cpp/language/integer_literal.

rsivek commented 6 years ago

Indeed it looks like the suffix was unnecessary. The mmHg definition in 3.x should probably be changed then for consistency.