Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | ritesh-ratnesh |
View: | 234 times |
Download: | 0 times |
of 24
8/3/2019 Scientific Calculator 111
1/24
SCIENTIFIC CALCULATOR
SUBMITED TO: SUBMITED BY:
Ms. Sukhdilpreet Kaur Name: Anuj Sharma
&Naman
Roll NO.:R246A16 & R246A11
Regn.No.: 10802451 &10800991
8/3/2019 Scientific Calculator 111
2/24
AKNOWLEDGMENTFirst and the foremost I would like to
thank to my almighty for giving me
courage to bring up this term assignment.
At the outset, I would like to propose aword of thanks to my teacher, friends and
other sources that gave an unending
support and helped me in numerous ways
from the first stage of my term
assignment conceived.
I would also like to thank my familymembers for their whole hearted support
and cooperation.
I duly acknowledge the contribution of
Ms.Sukhdilpreet Kaur for invaluable help.
Coding scientific calculator is an uphill
task and would have not been possible
without proper and timely assistance of
Ms.Sukhdilpreet Kaur.
8/3/2019 Scientific Calculator 111
3/24
I would also thanks to all my friends for
forwarding their suggestions to make
necessary modifications.
Special thanks to Ms.Sukhdilpreet
Kaur for her able guidance in my
term assignment.
INTRODUCTION
Scientific Calculator
The calculator was written by Rolf Howarth in early 1996.
8/3/2019 Scientific Calculator 111
4/24
A fully featured scientific calculator with proper operator precedence is
implemented, including trig functions and logarithms, factorials, 12
levels of parentheses, logs to base 2 (a handy function for information
entropists!), bitwise logical operators, hex, octal, binary and ASCII
display.
The calculator is written in JavaScript and you are welcome to view the
JavaScript source (visible within the HTML page) for personal
educational purposes as long as you recognize that it is copyrighted and
notin the public domain. This calculator is now available as part of
Hummingbird's Enterprise Information Portal. All enquiries regarding
licensing the calculator should be directed to Hummingbird Ltd.
Basic FunctionsAddition
The addition (sum function) is used by clicking on the "+" button or using the keyboard. Thefunction results in a+b.
Subtraction
The subtraction (minus function) is used by clicking on the "-" button or using the keyboard. Thefunction results in a-b.
Multiplication
The multiplication (times function) is used by clicking on the "x" button or using the keyboard
"*" key. The function results in a*b.
Division
The division (divide function) is used by clicking on the "/" button or using the keyboard "/" key.
The function results in a/b.
Sign
The sign key (negative key) is used by clicking on the "(-)" button. The function results in -1*x.
http://www.hummingbird.com/http://www.hummingbird.com/8/3/2019 Scientific Calculator 111
5/24
Square
The square function is used by clicking on the "x^2" button or type "^2". The function results in
x*x.
Square Root
The square root function is used by clicking on the "x" button or type "sqrt()". This function
represents x^.5 where the result squared is equal to x.
Raise to the Power
The raise to the power (y raised to the x function) is used by clicking on the "y^x" button or type
"^".
Natural Exponential
The natural exponential (e raised to the x) is used by clicking on the "e^x" button or type
"exp()". The result is e (2.71828...) raised to x.
Logarithm
The logarithm (LOG) is used by clicking on the "LOG" button or type "LOG()".
Natural Logarithm
The Natural logarithm (LN) is used by clicking on the "LN" button or type "LN()".
Inverse
Multiplicative inverse (reciprocal function) is used by pressing the "1/x" button or typing "inv()".
This function is the same as x^-1 or dividing 1 by the number.
Exponent
Numbers with exponents of 10 are displayed with an "e", for example 4.5e+100 or 4.5e-100.
This function represents 10^x. Numbers are automatically displayed in the format when the
number is too large or too small for the display. To enter a number in this format use the
exponent key "EEX". To do this enter the mantissa (the non exponent part) then press "EEX" ortype"e" and then enter the exponent.
Factorial
The Factorial function is used by clicking the "!" button or type "!".
8/3/2019 Scientific Calculator 111
6/24
PI
PI is a mathematical constant of the ratio of a circle's circumference to its diameter.
TABLE OF CONTENTS
INTRODUCTION
CODING
APPLICATIONS &
FUTUREPROSPECTIVEREFERENCES
8/3/2019 Scientific Calculator 111
7/24
CODING#include#include#include#include#include#include#include#include
#define pi 3.1415265
union REGS i,o;int sr,dpf;
char *no[]={"1","2","3","4","5","6","7","8","9","0",".","+/-"},*cal[]={"+","-","*","/","=",""},*sci[]={"Sin","Cos","Tan","Sinh","Cosh","Tanh","Exp","ln","log","xrty","
1/x","x^2","x^y","sqrt","fact","Hypot","eqn","DEG",},*ms[]={"AC","HEX","BIN","OCT","BKSP"};
long com(long,int);long double back(long double),equ(),alg(long double,int);double ns(long double,int);
8/3/2019 Scientific Calculator 111
8/24
int box(int,int,int,int,int);char *z2;long double *z1;int xy1[3];
void draw() //-----DRAW THE BODY OF CALCULATOR{int gm,gd=DETECT;int x,y,x1,y1,i,j;
initgraph(&gd,&gm,"c:\\tc\\bgi"); //INITIALISE GRAPHICS
z2=(char * ) malloc(sizeof(char)*10); /*ALLOCATE MEMORY TO z2*/
x=getmaxx();y=getmaxy();
setcolor(DARKGRAY); setfillstyle(1,CYAN); //CYAN outer bodyfloodfill(5,5,DARKGRAY);
setcolor(BLACK);setfillstyle(1,LIGHTGRAY);
rectangle(20,20,x-20,y-20); //grey calculator bodyfloodfill(50,50,BLACK);
setcolor(BLACK); //black outlineline(20,20,x-20,20);line(20,20,20,y-20);
setcolor(BLUE);setfillstyle(1,BLUE);rectangle(21,20,x-21,40);floodfill(25,25,BLUE); /* blue quit rectangle*/
setcolor(BLACK);outtextxy(x/5,8,"Scientific Calculator by-: Akash(02512) & Akhil(02514)");
initmouse();showmouse();setmouse(0,0);
setcolor(WHITE);setfillstyle(1,WHITE);rectangle(30,55,x-30,70); //---white i/o boxfloodfill(32,59,WHITE);
outtextxy(x-220,27,"Press Any Key To Quit."); //---Quitsetcolor(DARKGRAY);
line(235,95,235,y-30); //grey partition linesetfillstyle(1,LIGHTGRAY);
/*------------------printing nos.---------------------*/
i=0;for(x1=40;x1
8/3/2019 Scientific Calculator 111
9/24
setcolor(BLUE);if(i==1&&j==10)outtextxy(x1+10,y1+20,no[i+j]);
elseouttextxy(x1+15,y1+20,no[i+j]);
y1+=20; j+=2;}i++;x1+=40;
}
/*---------------------------------------------------------------*/
/*--------printing simple algebric functions:(+,-,*,/)----------*/
for(x1;x1
8/3/2019 Scientific Calculator 111
10/24
j++;}
}mouse();}
void main() //MAIN DECLARATION{password();draw();
}
/*-----------MOUSE PROGRAMMING------------*/
mouse(){int button,x,y;char s[13]={" "};int x1,y1,i,j,flag=1,l;long double n,k;
while(!kbhit()){ Again:
getmouse(&button,&x,&y);while(button==1){getmouse(&button,&x,&y);sr=1;}
if(sr==1){i=0;sr=0;if(x>=xy1[0]&&x=xy1[1]&&x=xy1[2]&&x
8/3/2019 Scientific Calculator 111
11/24
{ box(x1,y1,40,BLACK,WHITE);delay(200);box(x1,y1,40,WHITE,BLACK);
if((strcmp(no[i+j],no[11]))==0){ if(flag==1){ n*=-1; // +/- signs[0]='-';flag=0;
}else
{ n*=-1;s[0]=' ';setcolor(LIGHTGRAY);setfillstyle(1,WHITE);floodfill(32,59,LIGHTGRAY);flag=1;
}goto NEXT;
}
if(strlen(s)>=11)goto Again;
if((strcmp(no[i+j],no[10]))==0){if(dpf==0){
strcat(s,no[i+j]); //save no. to string sdpf=1;}
}else
strcat(s,no[i+j]); //save no. to strings
NEXT:n=_atold(s); //array to long doublesetcolor(DARKGRAY);outtextxy(30,60,s); // display no. in i/o box
goto Again;}
y1+=20; j+=2;}i++;x1+=40;
}
if(x>550 && x340 && y
8/3/2019 Scientific Calculator 111
12/24
s[l-1]=s[l];setcolor(DARKGRAY);outtextxy(30,60,s);goto Again;}
if(x>550 && x180 && x400 && y100 && y
8/3/2019 Scientific Calculator 111
13/24
i++;return 0;}
if(y>160 && y220 && y280 && y340 && y
8/3/2019 Scientific Calculator 111
14/24
}}elsei++;
} /*--------------*/
for(i=0;z2[i]!='\0';){if(z2[i]=='*') /*------perform multiplication------*/{z1[i]*=z1[i+1];for(j=i;z2[j]!='\0';j++){ z1[j+1]=z1[j+2];z2[j]=(int)z2[j+1];}
}elsei++; /*--------------*/}
for(i=0;z2[i]!='\0';){if(z2[i]=='+') /*------perform addition------*/{if(z2[i-1]=='-')z1[i+1]*=-1;
z1[i]+=z1[i+1];
for(j=i;z2[j]!='\0';j++){ z1[j+1]=z1[j+2];z2[j]=z2[j+1];}
}elsei++; /*--------------*/}
for(i=0;z2[i]!='\0';){if(z2[i]=='-') /*------perform subtraction------*/{z1[i]-=z1[i+1];for(j=i;z2[j]!='\0';j++){ z1[j+1]=z1[j+2];z2[j]=z2[j+1];}
}elsei++;} /*--------------*/
if(z2[1]=='r') /*------find yth roots------*/z1[0]=pow(z1[2],1/z1[0]);
8/3/2019 Scientific Calculator 111
15/24
if(z2[1]=='p') /*------find yth power------*/z1[0]=pow(z1[2],z1[0]);
if(z2[1]=='h') /*------find hypotenuse------*/z1[0]=hypot(z1[2],z1[0]);
gcvt(z1[0],15,ch); /*------copy result toarray----------*/setcolor(DARKGRAY);outtextxy(35,60,ch); //display result
press();return 0;}
/*-------perform numeric system calculations--------*/
double ns(long double b, int y )
{ int y1;long n;n=b;if(y>100 && y160 && y220 && y280 && y
8/3/2019 Scientific Calculator 111
16/24
{char *str;int i=0;itoa(b,str,k); // integer to arrayif(k==16){while(str[i]!='\0'){if(str[i]>96 && str[i]
8/3/2019 Scientific Calculator 111
17/24
setcolor(c1);setfillstyle(1,LIGHTGRAY);rectangle(x1,y1,x1+l,y1+40);floodfill(x1+3,y1+10,c1);setcolor(c2);line(x1+l,y1,x1+l,y1+40);line(x1,y1+40,x1+l,y1+40);return 0;
}
/*password at start screen*/
password(){int i,x=270,gm,gd=DETECT;char ch,pass[10];initgraph(&gd,&gm,"c:\\tc\\bgi");rectangle(15,15,615,465);setcolor(LIGHTBLUE);setfillstyle(1,LIGHTBLUE);
floodfill(50,50,15);settextstyle(1,HORIZ_DIR,3);setcolor(BLACK);outtextxy(200,50,"Enter the password");for(i=0;i=0;i--)
{setcolor(LIGHTBLUE);setfillstyle(1,LIGHTBLUE);bar(300,240,330,300);setcolor(RED);outtextxy(310,250,itoa(i,pass,10));sound(1000*i+500);
8/3/2019 Scientific Calculator 111
18/24
delay(300);nosound();delay(700);
}exit(0);return 0;}
/*-----------solving scientific functions------------*/
//---the no. entered is in RADIANS
/*-----------check for first column------------------*/colm1(long double a,int y){double cal;char *str;z1[2]=a;
setcolor(WHITE); setfillstyle(1,WHITE);bar(30,55,610,70);
if(y>=100 && y=160 && y=220 && y=280 && y=340 && y
8/3/2019 Scientific Calculator 111
19/24
box(xy1[0],340,70,WHITE,BLACK);z2[1]='p';return 0;
}if(y>=400 && y=100 && y=160 &&y=220 && y=280 && y
8/3/2019 Scientific Calculator 111
20/24
box(xy1[1],280,70,WHITE,BLACK);cal=1/a;}
if(y>=340 && y=400 && y=100 && y=160 && y=220 && y
8/3/2019 Scientific Calculator 111
21/24
}if(y>=280 && y=340 && y=1;a--)cal=cal*a;
}if(y>=400 && y
8/3/2019 Scientific Calculator 111
22/24
/*-----------------------END--------------------------------------*/
APPLICATIONS
In most countries, students use calculators for schoolwork.
There was some initial resistance to the idea out of fear that
basic arithmetic skills would suffer. There remains disagreement
about the importance of the ability to perform calculations "in
the head", with some curricula restricting calculator use until a
certain level of proficiency has been obtained, while others
concentrate more on teaching estimation techniques and
http://en.wikipedia.org/wiki/Studenthttp://en.wikipedia.org/wiki/Elementary_arithmetichttp://en.wikipedia.org/wiki/Estimationhttp://en.wikipedia.org/wiki/Studenthttp://en.wikipedia.org/wiki/Elementary_arithmetichttp://en.wikipedia.org/wiki/Estimation8/3/2019 Scientific Calculator 111
23/24
problem-solving. Research suggests that inadequate guidance in
the use of calculating tools can restrict the kind of mathematical
thinking that students engage in. Others have argued that
calculator use can even cause core mathematical skills toatrophy, or that such use can prevent understanding of advanced
algebraic concepts.
There are other concerns - for example, that a pupil could use
the calculator in the wrong fashion but believe the answer
because that was the result given. Teachers try to combat this by
encouraging the student to make an estimate of the result
manually and ensuring it roughly agrees with the calculatedresult. Also, it is possible for a child to type in 1 1 and
obtain the correct answer '1' without realizing the principle
involved. In this sense, the calculator becomes a crutch rather
than a learning tool, and it can slow down students in exam
conditions as they check even the most trivial result on a
calculator.
REFERENCES
1. Thomas J. Bing, Edward F. Redish, Symbolic Manipulators Affect Mathematical Mindsets,
December 2007
2. ^ Mike Sebastian's calculator forensics algorithmis an example of such rounding errors -- the
algorithm's arcsin(arccos(arctan(tan(cos(sin(9)))))) should come out 9 on standard floating pointhardware, but for CORDIC it's a pathological case that produces different rounding errors on
each chip that it is implemented on. The algorithm is primarily used to identify the manufacturer
of a particular calculator's CPU, since it is usually reproducible between chips of the same model.
http://en.wikipedia.org/wiki/Crutchhttp://arxiv.org/abs/0712.1187http://en.wikipedia.org/wiki/Calculator#cite_ref-1http://www.rskey.org/~mwsebastian/miscprj/algorithm.htmhttp://www.rskey.org/~mwsebastian/miscprj/algorithm.htmhttp://en.wikipedia.org/wiki/Crutchhttp://arxiv.org/abs/0712.1187http://en.wikipedia.org/wiki/Calculator#cite_ref-1http://www.rskey.org/~mwsebastian/miscprj/algorithm.htm8/3/2019 Scientific Calculator 111
24/24
3. ^ Georges Ifrahnotes that humans learned to count on their hands. Ifrah shows, for example, a
picture ofBoethius (who lived 480524 or 525) reckoning on his fingers inIfrah 2000, p. 48.
4. ^ According to Schmandt-Besserat 1981, these clay containers contained tokens, the total of
which were the count of objects being transferred. The containers thus served as abill of lading
or an accounts book. In order to avoid breaking open the containers, marks were placed on the
outside of the containers, for the count. Eventually (Schmandt-Besserat estimates it took 4000
years) the marks on the outside of the containers were all that were needed to convey the count,and the clay containers evolved into clay tablets with marks for the count.
5. ^ Lazos 1994
6. ^Ancient Discoveries, Episode 11: Ancient Robots,History Channel,
http://www.youtube.com/watch?v=rxjbaQl0ad8, retrieved on 6 September 2008
7. ^ A Spanish implementation ofNapier's bones(1617), is documented in Montaner i Simon 1887,
pp. 19-20.
8. ^ Kells, Kern & Bland 1943, p. 92
9. ^ Kells, Kern & Bland 1943, p. 82, as log(2)=.3010, or 4 places.
10.^ Schmidhuber
11.^ As quoted in Smith 1929, pp. 180-181
12.^ Slide Rules
13.^ Smart Computing Article - Calculating Clock to Carnegie Mellon University14.^ IBM Archives: IBM 608 calculator
15.^ "Simple and Silent", Office Magazine, Dec. 1961, p1244
16.^ "'Anita' der erste tragbare elektonische Rechenautomat" [trans: "the first portable electronic
computer"],Buromaschinen Mechaniker, Nov. 1961, p207
17.^ Texas Instruments Celebrates the 35th Anniversary of Its Invention of the CalculatorTexas
Instrumentspress release, 15 Aug 2002.
18.^ Electronic Calculator Invented 40 Years Ago All Things Considered, NPR, 30 Sept 2007.
Audio interview with one of the inventors.
19.^ "Single Chip Calculator Hits the Finish Line",Electronics's', Feb. 1 1971, p19
http://en.wikipedia.org/wiki/Calculator#cite_ref-2http://en.wikipedia.org/wiki/Georges_Ifrahhttp://en.wikipedia.org/wiki/Georges_Ifrahhttp://en.wikipedia.org/wiki/Boethiushttp://en.wikipedia.org/wiki/Calculator#CITEREFIfrah2000http://en.wikipedia.org/wiki/Calculator#CITEREFIfrah2000http://en.wikipedia.org/wiki/Calculator#cite_ref-3http://en.wikipedia.org/wiki/Calculator#CITEREFSchmandt-Besserat1981http://en.wikipedia.org/wiki/Bill_of_ladinghttp://en.wikipedia.org/wiki/Calculator#cite_ref-4http://en.wikipedia.org/wiki/Calculator#CITEREFLazos1994http://en.wikipedia.org/wiki/Calculator#cite_ref-Ancient_Discoveries_5-0http://en.wikipedia.org/wiki/Ancient_Discoverieshttp://en.wikipedia.org/wiki/History_Channelhttp://en.wikipedia.org/wiki/History_Channelhttp://www.youtube.com/watch?v=rxjbaQl0ad8http://www.youtube.com/watch?v=rxjbaQl0ad8http://en.wikipedia.org/wiki/Calculator#cite_ref-6http://en.wikipedia.org/wiki/Napier's_boneshttp://en.wikipedia.org/wiki/Napier's_boneshttp://en.wikipedia.org/wiki/Calculator#CITEREFMontaner_i_Simon1887http://en.wikipedia.org/wiki/Calculator#cite_ref-7http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#cite_ref-8http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#cite_ref-9http://en.wikipedia.org/wiki/Calculator#CITEREFSchmidhuberhttp://en.wikipedia.org/wiki/Calculator#CITEREFSchmidhuberhttp://en.wikipedia.org/wiki/Calculator#cite_ref-10http://en.wikipedia.org/wiki/Calculator#CITEREFSmith1929http://en.wikipedia.org/wiki/Calculator#cite_ref-11http://www.hpmuseum.org/sliderul.htmhttp://en.wikipedia.org/wiki/Calculator#cite_ref-12http://www.smartcomputing.com/editorial/article.asp?article=articles/archive/r0601/c2/calculatingclocktocarnegiemelon.asphttp://en.wikipedia.org/wiki/Calculator#cite_ref-13http://www-03.ibm.com/ibm/history/exhibits/vintage/vintage_4506VV2214.htmlhttp://en.wikipedia.org/wiki/Calculator#cite_ref-14http://en.wikipedia.org/wiki/Calculator#cite_ref-15http://en.wikipedia.org/wiki/Calculator#cite_ref-16http://education.ti.com/educationportal/sites/US/nonProductSingle/about_press_release_news37.htmlhttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Calculator#cite_ref-17http://www.npr.org/templates/story/story.php?storyId=14845433http://en.wikipedia.org/wiki/Calculator#cite_ref-18http://en.wikipedia.org/wiki/Calculator#cite_ref-2http://en.wikipedia.org/wiki/Georges_Ifrahhttp://en.wikipedia.org/wiki/Boethiushttp://en.wikipedia.org/wiki/Calculator#CITEREFIfrah2000http://en.wikipedia.org/wiki/Calculator#cite_ref-3http://en.wikipedia.org/wiki/Calculator#CITEREFSchmandt-Besserat1981http://en.wikipedia.org/wiki/Bill_of_ladinghttp://en.wikipedia.org/wiki/Calculator#cite_ref-4http://en.wikipedia.org/wiki/Calculator#CITEREFLazos1994http://en.wikipedia.org/wiki/Calculator#cite_ref-Ancient_Discoveries_5-0http://en.wikipedia.org/wiki/Ancient_Discoverieshttp://en.wikipedia.org/wiki/History_Channelhttp://www.youtube.com/watch?v=rxjbaQl0ad8http://en.wikipedia.org/wiki/Calculator#cite_ref-6http://en.wikipedia.org/wiki/Napier's_boneshttp://en.wikipedia.org/wiki/Calculator#CITEREFMontaner_i_Simon1887http://en.wikipedia.org/wiki/Calculator#cite_ref-7http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#cite_ref-8http://en.wikipedia.org/wiki/Calculator#CITEREFKellsKernBland1943http://en.wikipedia.org/wiki/Calculator#cite_ref-9http://en.wikipedia.org/wiki/Calculator#CITEREFSchmidhuberhttp://en.wikipedia.org/wiki/Calculator#cite_ref-10http://en.wikipedia.org/wiki/Calculator#CITEREFSmith1929http://en.wikipedia.org/wiki/Calculator#cite_ref-11http://www.hpmuseum.org/sliderul.htmhttp://en.wikipedia.org/wiki/Calculator#cite_ref-12http://www.smartcomputing.com/editorial/article.asp?article=articles/archive/r0601/c2/calculatingclocktocarnegiemelon.asphttp://en.wikipedia.org/wiki/Calculator#cite_ref-13http://www-03.ibm.com/ibm/history/exhibits/vintage/vintage_4506VV2214.htmlhttp://en.wikipedia.org/wiki/Calculator#cite_ref-14http://en.wikipedia.org/wiki/Calculator#cite_ref-15http://en.wikipedia.org/wiki/Calculator#cite_ref-16http://education.ti.com/educationportal/sites/US/nonProductSingle/about_press_release_news37.htmlhttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Texas_Instrumentshttp://en.wikipedia.org/wiki/Calculator#cite_ref-17http://www.npr.org/templates/story/story.php?storyId=14845433http://en.wikipedia.org/wiki/Calculator#cite_ref-18