Skip to content

guzlewski/Rational

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Rational

C++ class implementing rational numbers. Avaible operators: +, -, *, /, <<, >>, ==, !=, >, >=, <, <=. Exponentiation with integer exponents is also available. Object Rational is auto shortening after every operation.

Example

#include "Rational.hpp"

int main()
{
	guzlewski::Rational r1, r2, result;

	std::cin >> r1 >> r2;
	result = r1 + r2;
	std::cout << r1 << " + " << r2 << " = " << result << std::endl;

	return 0;
}
2|8 -5|13
1|4 + -5|13 = -7|52

About

C++ class implementing rational numbers

Topics

Resources

License

Stars

Watchers

Forks

Languages