|
occ
|
Class representing and holding data a rational number i.e. More...
#include <fraction.h>
Public Member Functions | |
| Fraction ()=default | |
| Default constructor 0/1. | |
| Fraction (int64_t, int64_t) | |
| Constructor from two ints. | |
| Fraction (double) | |
| Constructor from double, will find the nearest representation. | |
| Fraction (int64_t) | |
| Constructor from one int i.e. x/1. | |
| Fraction (const std::string &) | |
| Constructor from string, will try to parse expressions like x/y. | |
| std::string | to_string () const |
| represent this fraction as a string | |
| template<typename T > | |
| T | cast () const |
| const Fraction | simplify () const |
| reduce this fraction by removing common factors in numerator/denominator | |
| const Fraction | limit_denominator (int64_t max_denominator=1000000) const |
| restrict this fraction to have a maximum denominator (i.e. round it) | |
| const Fraction | abs () const |
| Absolute value of this fraction. | |
| const Fraction | add (const Fraction &other) const |
| Add this fraction to another. | |
| const Fraction | subtract (const Fraction &other) const |
| Subtract another fraction from this fraction. | |
| const Fraction | multiply (const Fraction &other) const |
| Multiply this fraction with another fraction. | |
| const Fraction | divide (const Fraction &other) const |
| Divide this fraction by another fraction. | |
| const Fraction | operator+ (const Fraction &) const |
| operator overload for Fraction::add | |
| const Fraction | operator- (const Fraction &) const |
| operator overload for Fraction::subtract | |
| const Fraction | operator* (const Fraction &) const |
| operator overload for Fraction::multiply | |
| const Fraction | operator/ (const Fraction &) const |
| operator overload for Fraction::divide | |
| auto | operator== (const Fraction &) const -> bool |
| auto | operator== (int64_t) const -> bool |
| auto | operator< (const Fraction &) const -> bool |
| auto | operator<= (const Fraction &) const -> bool |
Class representing and holding data a rational number i.e.
|
default |
Default constructor 0/1.
| occ::core::Fraction::Fraction | ( | int64_t | , |
| int64_t | |||
| ) |
Constructor from two ints.
| occ::core::Fraction::Fraction | ( | double | ) |
Constructor from double, will find the nearest representation.
| occ::core::Fraction::Fraction | ( | int64_t | ) |
Constructor from one int i.e. x/1.
| occ::core::Fraction::Fraction | ( | const std::string & | ) |
Constructor from string, will try to parse expressions like x/y.
| const Fraction occ::core::Fraction::abs | ( | ) | const |
Absolute value of this fraction.
Add this fraction to another.
Divide this fraction by another fraction.
| const Fraction occ::core::Fraction::limit_denominator | ( | int64_t | max_denominator = 1000000 | ) | const |
restrict this fraction to have a maximum denominator (i.e. round it)
Multiply this fraction with another fraction.
operator overload for Fraction::multiply
operator overload for Fraction::add
operator overload for Fraction::subtract
operator overload for Fraction::divide
| auto occ::core::Fraction::operator< | ( | const Fraction & | ) | const -> bool |
| auto occ::core::Fraction::operator<= | ( | const Fraction & | ) | const -> bool |
| auto occ::core::Fraction::operator== | ( | const Fraction & | ) | const -> bool |
| auto occ::core::Fraction::operator== | ( | int64_t | ) | const -> bool |
| const Fraction occ::core::Fraction::simplify | ( | ) | const |
reduce this fraction by removing common factors in numerator/denominator
Subtract another fraction from this fraction.
| std::string occ::core::Fraction::to_string | ( | ) | const |
represent this fraction as a string