#include <windows.h>
#include <stdio.h>
#include "StringEx.h"
#include "Integer.h"
#include "Rational.h"
#include "Contextualize.h"
void main()
{
{
Integer a( 3 );
Integer b( 2 );
Integer c( 3452 );
wprintf( TEXT("%s\n"), (LPCTSTR)c.Print() );
c += b;
wprintf( TEXT("%s\n"), (LPCTSTR)c.Print() );
Integer d = a * b + c;
wprintf( TEXT("%s\n"), (LPCTSTR)d.Print() );
c--;
wprintf( TEXT("%s\n"), (LPCTSTR)c.Print() );
b--;
wprintf( TEXT("%s\n"), (LPCTSTR)b.Print() );
}
{
Rational a( contextualize< Integer as sX::Numerator >::Initialize( 2 ),
contextualize< Integer as sX::Denominator >::Initialize( 3 ) );
Rational b( contextualize< Integer as sX::Numerator >::Initialize( 3 ),
contextualize< Integer as sX::Denominator >::Initialize( 4 ) );
Rational c( contextualize< Integer as sX::Numerator >::Initialize( 7 ),
contextualize< Integer as sX::Denominator >::Initialize( 2 ) );
Rational d( -5 );
Rational e = ((a + b ) * c) / (d - 456 * c);
wprintf(TEXT("e=%s; e (as floating approximation) = %.16f\n"), (LPCTSTR)e.Print(), e.GetAsDouble());
}
}
|