11#ifndef PBAT_MATH_RATIONAL_H
12#define PBAT_MATH_RATIONAL_H
14#include "PhysicsBasedAnimationToolkitExport.h"
42 template <std::
integral Integer>
44 :
a(static_cast<std::int64_t>(_a)),
b(static_cast<std::int64_t>(_b))
54 template <std::
integral Integer>
55 Rational(Integer value) :
a(static_cast<std::int64_t>(value)),
b(1)
92 bool operator==(
Rational const& other)
const;
98 bool operator<(
Rational const& other)
const;
105 bool Rebase(std::int64_t denominator);
111 explicit operator double()
const;
117 explicit operator float()
const;
135template <std::
integral Integer>
149template <std::
integral Integer>
163template <std::
integral Integer>
177template <std::
integral Integer>
Math related functionality.
Definition Concepts.h:19
Rational operator-(Integer a, Rational const &b)
Subtraction operation between Rational and integral type.
Definition Rational.h:136
Rational operator*(Integer a, Rational const &b)
Multiplication operation between Rational and integral type.
Definition Rational.h:164
Rational operator/(Integer a, Rational const &b)
Division operation between Rational and integral type.
Definition Rational.h:178
Rational operator+(Integer a, Rational const &b)
Addition operation between Rational and integral type.
Definition Rational.h:150
The main namespace of the library.
Definition Aliases.h:15
Fixed size rational number using std::int64_t for numerator and denominator.
Definition Rational.h:29
Rational(Integer _a, Integer _b)
Construct a new Rational object.
Definition Rational.h:43
Rational()
Construct a new Rational object.
Definition Rational.cpp:11
std::int64_t a
Numerator.
Definition Rational.h:123
Rational(Integer value)
Construct a new Rational object.
Definition Rational.h:55
std::int64_t b
Denominator.
Definition Rational.h:124