I am going to talk about Mathematical Precision of Computer Programming Languages in this Article...I saw some Articles where there were some people who wanted to know the Factorial of 100...So I solved the problem in 3 languages to check the Mathematical Precision and this is what I got as Result.....
/*---------------------------Program in C--------------------------*/
#include
#include
void main(void)
{
double num,fact,i;clrscr(); fact=1.00;
printf("\n\n\tPlease Enter the Number: ");
scanf("%lf",&num);
for(i=1;i<=num;i++)
fact=fact*i;
printf("\aThe Number is: %lf ",fact); getch();
}/*-----------------------End of Main-------------------------*/
OUTPUT: 9.33621544394410220000000000000000e+157
/*-------------------PROGRAM IN JAVA--------------------------------*/
import java.io.*;
class Factorial{
public static void main(String args[]) {
double a=0,i,f=1;
try {
System.out.print("\n\n\tPlease Enter the Number: ");
DataInputStream d=new DataInputStream(System.in);
a=Integer.parseInt(d.readLine());
}catch(Exception e) { }
for(i=a;i>0;i--)
f*=i;
System.out.println("The Factorial of "+a+" is "+f);
}
}/*-----------------------End of Class Factorial----------------------------*/
OUTPUT: 9.336215443944118E157
//------------------------PROGRAM IN C#.NET--------------------------//
using.System.Data;
class Fact
{
private double num,fact,i;
public Fact( )
{
this.fact=1;
}
public void input( ){
Console.Write("\n\tPlease Enter the Number upto which you want to See: ");
num=int.Parse(Console.ReadLine( ));
}
public void calculate( ){
for(i=1;i<=num;i++)
fact*=i;
Console.Write("\n\tThe Factorial of"+num+" is :"+fact);
}
public static void main(String [] args) {
Fact fac=new Fact ( );
fac.input( );
fac.calculate( );
}
}/*--------------------------End of C# Program-------------------------------*/
OUTPUT: 9.336215443944102E+157
//-----------------------------------------------------------------//
Comments: So you see from the above examples that the Languages are getting Richer and more Advanced the Mathematical Precision decreases. The Modern Languages are meant for all Practical Purposes and real Life problem Solving so they are not very Precise but they deal with the Data more Effectively...............
