Skip to content
Browse files

FixedInt - round instead of truncate on construction

This could have caused issues where e.g. Fixed100(59.94) differed from
Fixed100::fromString("59.94") due to precision compilation flags
(the former could, and did on Devel builds, end up with Raw == 5993, which
differs from the value constructed from the string at the ini file,
and then it would be incorrectly identified as a custom rate).

Rounding seems the more likely intention when effectively decreasing the
precision of a value.

Unlikely that we have code which depends on truncating behavior, though not
  • Loading branch information...
avih committed Sep 16, 2015
1 parent 2d97f6d commit d10bbb73f78379270a6a9f09f7c8b871075b89ef
Showing with 2 additions and 2 deletions.
  1. +2 −2 common/include/Utilities/FixedPointTypes.inl
@@ -33,13 +33,13 @@ FixedInt<Precision>::FixedInt( int signedval )
template< int Precision >
FixedInt<Precision>::FixedInt( double doubval )
Raw = (int)(doubval * (double)Precision);
Raw = lround(doubval * (double)Precision);

template< int Precision >
FixedInt<Precision>::FixedInt( float floval )
Raw = (int)(floval * (float)Precision);
Raw = lroundf(floval * (float)Precision);

template< int Precision >

0 comments on commit d10bbb7

Please sign in to comment.
You can’t perform that action at this time.