Improve ternary consistency within Utils.h (#57)

pull/58/head
Pharap 6 years ago committed by GitHub
parent 299199c98b
commit 096cd8cc83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/FixedPoints/Utils.h

@ -135,9 +135,9 @@ constexpr SFixed<Integer, Fraction> roundFixed(const SFixed<Integer, Fraction> &
{ {
using OutputType = SFixed<Integer, Fraction>; using OutputType = SFixed<Integer, Fraction>;
return return
signbitFixed(value) signbitFixed(value) ?
? (value.getFraction() <= OutputType(0.5).getFraction()) ? floorFixed(value) : ceilFixed(value) ((value.getFraction() <= OutputType(0.5).getFraction()) ? floorFixed(value) : ceilFixed(value)) :
: (value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value); ((value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value));
} }
template< unsigned Integer, unsigned Fraction > template< unsigned Integer, unsigned Fraction >
@ -182,7 +182,7 @@ constexpr SFixed<Integer, Fraction> nextafterFixed(const SFixed<Integer, Fractio
(from < to) ? (from < to) ?
ResultType::fromInternal(from.getInternal() + 1) : ResultType::fromInternal(from.getInternal() + 1) :
(from > to) ? (from > to) ?
ResultType::fromInternal(from.getInternal() - 1): ResultType::fromInternal(from.getInternal() - 1) :
to; to;
} }
@ -194,7 +194,7 @@ constexpr UFixed<Integer, Fraction> nextafterFixed(const UFixed<Integer, Fractio
(from < to) ? (from < to) ?
ResultType::fromInternal(from.getInternal() + 1) : ResultType::fromInternal(from.getInternal() + 1) :
(from > to) ? (from > to) ?
ResultType::fromInternal(from.getInternal() - 1): ResultType::fromInternal(from.getInternal() - 1) :
to; to;
} }

Loading…
Cancel
Save