calc/examples/kontrolnibod.cpp

81 lines
2.1 KiB
C++
Raw Normal View History

2024-03-08 15:27:04 +01:00
#include "../src/code/rational.cpp"
#include <assert.h>
int main( void ) {
{
// CBigInt a(3), b(5);
// auto c = b.lcm(&a);
// delete c;
// delete c;
// CBigInt *c = a.add(&b);
// assert( CBigInt(1111111110).cmp(c) == 0);
// delete c;
// c = a.sub(&b);
// assert( CBigInt(-864197532).cmp(c) == 0);
// delete c;
}
// {
// CBigInt a(123456789), b(987654321);
// auto c = b.divmod(&a);
// assert( CBigInt(8).cmp(c.first) == 0 );
// assert( CBigInt(9).cmp(c.second) == 0 );
// delete c.first;
// delete c.second;
// }
// //! leak
// {
// CRational a( new CBigInt(1), new CBigInt(6) );
// CRational b( new CBigInt(2), new CBigInt(6) );
// CRational d( new CBigInt(11),new CBigInt(15) );
// a.setSameDenominator(&b);
// CRational *c = a.add(&b);
// c->simplify();
// // assert( d.toString() == c->toString());
// delete c;
// }
// {
// CRational a( new CBigInt(123), new CBigInt(456) );
// CRational b( new CBigInt(789), new CBigInt(123) );
// CRational d( new CBigInt(41657),new CBigInt(6232) );
// CRational *c = a.add(&b);
// c->simplify();
// // assert( d.toString() == c->toString());
// delete c;
// }
// //! leak
// {
// CRational a( new CBigInt(1), new CBigInt(3) );
// CRational b( new CBigInt(2), new CBigInt(5) );
// CRational d( new CBigInt(2),new CBigInt(15) );
// CRational *c = a.mul(&b);
// c->simplify();
// // assert( d.toString() == c->toString());
// delete c;
// }
// {
// CBigInt a(12), b(-4);
// CBigInt *c = a.div(&b);
// // c->debugPrint();
// delete c;
// }
// {
// CRational a( new CBigInt(-1), new CBigInt(3) );
// CRational b( new CBigInt(-1), new CBigInt(2) );
// CRational *c = a.div(&b);
// c->simplify();
// auto str = c->toString();
// // std::cout << str << '\n';
// delete c;
// }
{
CRational a( new CBigInt(3), new CBigInt(7));
CRational *c = a.exp();
auto str = c->toString();
std::cout << c->debugDump() << '\n';
delete c;
}
return 0;
}