= 0.5; otherwise, behaves as for Down. * Note that this is the rounding mode commonly taught at school. */ case HalfUp; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. * * Behaves as for Up if the discarded fraction is > 0.5; otherwise, behaves as for Down. */ case HalfDown; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity. * * If the result is positive, behaves as for HalfUp; if negative, behaves as for HalfDown. */ case HalfCeiling; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity. * * If the result is positive, behaves as for HalfDown; if negative, behaves as for HalfUp. */ case HalfFloor; /** * Rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case rounds towards the even neighbor. * * Behaves as for HalfUp if the digit to the left of the discarded fraction is odd; * behaves as for HalfDown if it's even. * * Note that this is the rounding mode that statistically minimizes * cumulative error when applied repeatedly over a sequence of calculations. * It is sometimes known as "Banker's rounding", and is the default rounding mode in IEEE 754. */ case HalfEven; }