MBBSoftware Our Public Authentication Key (?) Our Public Encryption Key (?)
  Products Downloads Learning Support Store Blog About  Welcome Guest  |Login| My Account  
How to Use the Proper Numbers Library
Proper Numbers Library Home How to Use Download License Text  
 
Proper Numbers Library Icon
How to Use the Proper Numbers Library

C++ source code using the Proper Numbers Library.

To start using the Proper Numbers Library in a project, simply copy the supplied header files in a folder on a path included in your project and #include the required of them in the files where they are needed. Simple use of the Proper Numbers Library is shown in the code below.
#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());
   }
}
Community Content
(To enter your comments you must be signed in. Log in or create FREE account.)
MemberComments
Be the first to comment.
 
   
© Copyright 2012 MBBSoftware Limited. All Rights Reserved. Disclaimer Privacy Antispam Email this page
Buy Now
Download
Get Account
Get Newsletter
X
Email this page
To:
use semicolon to separate emails eg: [email protected]; [email protected]
Subject:
Message:
a link to this page will be automatically added to your message
From:
Please type the anti-bot text below.
Type text:  

Thank you for subscribing to the MBBSoftware newsletter.
Please enter your email address:
Please type the anti-bot text below.
Type text: