knotkit/algebra/Q.cpp
2011-12-09 15:50:25 -05:00

20 lines
238 B
C++

#include <algebra/algebra.h>
void
Q::reduce ()
{
unsigned c = unsigned_gcd ((unsigned)std::abs (n), d);
n /= (int)c;
d /= c;
}
void
Q::show_self () const
{
if (d == 1)
printf ("%d", n);
else
printf ("%d/%u", n, d);
}