21 template <
typename UIntegerType>
42 operator float()
const;
43 operator double()
const;
54 inline BSNumber<UIntegerType>
const&
GetNumerator()
const;
55 inline BSNumber<UIntegerType>
const&
GetDenomator()
const;
82 bool Write(std::ofstream& output)
const;
88 template <
typename UIntType,
typename RealType>
91 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 104 template <
typename UIntegerType>
110 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 111 mValue = (double)*
this;
115 template <
typename UIntegerType>
121 template <
typename UIntegerType>
127 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 128 mValue = (double)*
this;
132 template <
typename UIntegerType>
138 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 139 mValue = (double)*
this;
143 template <
typename UIntegerType>
149 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 150 mValue = (double)*
this;
154 template <
typename UIntegerType>
160 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 161 mValue = (double)*
this;
165 template <
typename UIntegerType>
171 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 172 mValue = (double)*
this;
176 template <
typename UIntegerType>
182 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 183 mValue = (double)*
this;
187 template <
typename UIntegerType>
193 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 194 mValue = (double)*
this;
198 template <
typename UIntegerType>
210 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 211 mValue = (double)*
this;
215 template <
typename UIntegerType>
227 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 228 mValue = (double)*
this;
232 template <
typename UIntegerType>
254 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 255 mValue = (double)*
this;
259 template <
typename UIntegerType>
262 return Convert<uint32_t, float>();
265 template <
typename UIntegerType>
268 return Convert<uint64_t, double>();
271 template <
typename UIntegerType>
277 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 278 mValue = (double)*
this;
283 template <
typename UIntegerType>
286 *
this = std::move(
r);
289 template <
typename UIntegerType>
294 #if defined(GTE_BINARY_SCIENTIFIC_SHOW_DOUBLE) 295 mValue = (double)*
this;
300 template <
typename UIntegerType>
inline 306 template <
typename UIntegerType>
inline 312 template <
typename UIntegerType>
inline 318 template <
typename UIntegerType>
335 template <
typename UIntegerType>
341 template <
typename UIntegerType>
347 if (r.mNumerator.mSign <= 0)
354 return r.mNumerator.mSign > 0;
358 if (r.mNumerator.mSign >= 0)
367 template <
typename UIntegerType>
373 template <
typename UIntegerType>
376 return r.operator<(*this);
379 template <
typename UIntegerType>
385 template <
typename UIntegerType>
391 template <
typename UIntegerType>
397 template <
typename UIntegerType>
406 if (numerator.
mSign != 0)
417 template <
typename UIntegerType>
426 if (numerator.
mSign != 0)
437 template <
typename UIntegerType>
444 if (numerator.
mSign != 0)
455 template <
typename UIntegerType>
459 LogAssert(r.mNumerator.mSign != 0,
"Division by zero not allowed.");
464 if (numerator.
mSign != 0)
467 if (denominator.
mSign < 0)
470 denominator.
mSign = 1;
480 template <
typename UIntegerType>
488 template <
typename UIntegerType>
496 template <
typename UIntegerType>
504 template <
typename UIntegerType>
512 template <
typename UIntegerType>
518 template <
typename UIntegerType>
524 template <
typename UIntegerType>
525 template <
typename UIntType,
typename RealType>
538 int32_t sign = n.
mSign * d.mSign;
543 d.mBiasedExponent = 1 - d.GetUInteger().GetNumBits();
557 int const imax = std::numeric_limits<RealType>::digits - 1;
559 UIntType
mask = ((UIntType)1 << imax);
560 for (
int i = imax; i >= 0; --i, mask >>= 1)
582 if (n.
mSign > 0 || (n.
mSign == 0 && (w & 1) == 1))
599 RealType converted = (RealType)result;
602 converted = -converted;
617 template <
typename UIntegerType>
inline 621 return (number.
GetSign() >= 0 ? number : -number);
BSRational & operator-=(BSRational const &r)
GTE_IMPEXP int32_t GetTrailingBit(uint32_t value)
UIntegerType const & GetUInteger() const
BSNumber< UIntegerType > mNumerator
#define LogAssert(condition, message)
bool Write(std::ofstream &output) const
bool operator==(BSRational const &r) const
int32_t GetExponent() const
GLubyte GLubyte GLubyte GLubyte w
friend class UnitTestBSRational
BSRational operator-() const
BSRational & operator+=(BSRational const &r)
BSNumber< UIntegerType > mDenominator
BSRational operator*(BSRational const &r) const
gte::BSRational< UIntegerType > abs(gte::BSRational< UIntegerType > const &number)
bool operator<=(BSRational const &r) const
INT32 INT32 * denominator
BSNumber< UIntegerType > const & GetNumerator() const
GLenum GLenum GLenum input
bool operator>=(BSRational const &r) const
BSRational & operator*=(BSRational const &r)
bool Read(std::ifstream &input)
BSRational & operator/=(BSRational const &r)
BSRational operator+() const
bool operator>(BSRational const &r) const
BSRational & operator=(BSRational const &r)
BSNumber< UIntegerType > const & GetDenomator() const
bool operator<(BSRational const &r) const
BSRational operator/(BSRational const &r) const
bool operator!=(BSRational const &r) const