Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Protung Dragos  >  Big Number Calculator  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of usage
Class: Big Number Calculator
Add arbitrary precision numbers in pure PHP
Author: By
Last change: One more example
Date: 2006-11-29 05:41
Size: 907 bytes
 

Contents

Class file image Download
<?php

require_once("calculator.php");


// example 1
$calc = new calculator();

$calc->addNumber("9283476109487129740712657109832.21341234");
$calc->addNumber("4386120876213943720417240982137.43937502");
$result $calc->calc();

print 
"\nThe result is: ".$result."\n\n\n";





// example 2
$calc = new calculator();
// generate a very big numer
$number  "8347610948712974071265710983243861208762139437204172409821378273618976529283476109487129740712657109";
$number str_repeat($number10000);


$calc->addNumber($number);
$calc->addNumber($number);

$time_start microtime(true);
$result $calc->calc();
$time_end microtime(true);

print 
"\nThe number has ".strlen($number)." digits. ";
print 
"\nThe result has ".strlen($result)." digits. ";

print 
"\nThe result is: ".$result;


print 
"\nThe sum was executed in ".($time_end-$time_start)." seconds.";

?>