TinyFractionsPP
Precise fraction math for C++ — no decimal drift, no rounding errors. Built for mathematicians, physicists, and engineers who demand accuracy.
View on GitHubWhy TinyFractionsPP?
Floating-point arithmetic is fast but imprecise. TinyFractionsPP keeps your numbers as exact fractions — preserving every digit through multiplication, division, and exponentiation. Perfect for scientific computing, physics simulations, and any project where precision matters.
Create fractions from integers, doubles, or even other fractions. Compare, add, subtract, multiply, divide, and raise to a power — all without losing accuracy to decimal conversion.
Install
Clone this repository by https or ssh:
Configure:
And build:
In CMakeLists.txt at your project insert:
Now it's easy to import my library from any source file:
Usage
All methods and classes are int namespace fr.
Fractions class: fr::CommonFraction.
Constructors:
(int64,int64)(int64)(double,double)(double)(CommonFraction, CommonFraction)
Methods:
print(string start, string end) → voidgetFull() → pair(int64,int64)getNumerator() → int64getDenominator() → unsigned int64getDecimal() → double
Functions:
fr::power(fr::CommonFraction, int) → fr::CommonFractionfr::bring(fr::CommonFraction, fr::CommonFraction) → pair<CommonFraction,CommonFraction>
Operators:
+-*/
Comparison and arithmetic operators work between fractions as well as with int and double.
License
Apache2.0 © Apache Software Foundation