Page 1 of 2 [ 21 posts ]  Go to page 1, 2  Next


Have you wrote a calculator?
Yes 29%  29%  [ 14 ]
Yes 29%  29%  [ 14 ]
no 21%  21%  [ 10 ]
no 21%  21%  [ 10 ]
Total votes : 48

mic
Hummingbird
Hummingbird

User avatar

Joined: 24 Jun 2004
Gender: Male
Posts: 23

30 Jun 2004, 10:12 am

I tried to write one in C++ but failed. In whatever language you know have you wrote a calculator.



Bruno
Hummingbird
Hummingbird

User avatar

Joined: 7 Jul 2004
Gender: Male
Posts: 22

10 Jul 2004, 9:38 am

I did some math helping tools in flash, quite useful.



MoonPatrol
Emu Egg
Emu Egg

User avatar

Joined: 26 Jun 2004
Gender: Male
Posts: 6

10 Jul 2004, 6:53 pm

What sort of calculator? One of those ones with the buttons? I wrote a simple one of those once in Smalltalk.



synx13
Pileated woodpecker
Pileated woodpecker

User avatar

Joined: 4 Jul 2004
Gender: Female
Posts: 175
Location: California Central Valley

11 Jul 2004, 5:28 pm

Writing a calculator is a pretty standard exercise for those studying language parsers. I've put together one before.



MoonPatrol
Emu Egg
Emu Egg

User avatar

Joined: 26 Jun 2004
Gender: Male
Posts: 6

11 Jul 2004, 7:16 pm

I'm unclear about what we are talking about here. Are we talking about an expression evaluator that you give a string like say "3 * 2 + 5" and it comes back with a result, or are we talking about a "desktop" calculator that has buttons you can click?



Tom_FL_MA
Deinonychus
Deinonychus

User avatar

Joined: 4 Jul 2004
Age: 46
Gender: Male
Posts: 304
Location: Central Florida; originally southeastern Massachusetts

11 Jul 2004, 7:25 pm

I am a perplexed myself, MoonPatrol.



mic
Hummingbird
Hummingbird

User avatar

Joined: 24 Jun 2004
Gender: Male
Posts: 23

12 Jul 2004, 2:27 pm

Quote:
Are we talking about an expression evaluator that you give a string like say "3 * 2 + 5" and it comes back with a result

That type of calculator is what I mean.



Tom_FL_MA
Deinonychus
Deinonychus

User avatar

Joined: 4 Jul 2004
Age: 46
Gender: Male
Posts: 304
Location: Central Florida; originally southeastern Massachusetts

12 Jul 2004, 4:01 pm

I get it, interesting term to give it. :)



MoonPatrol
Emu Egg
Emu Egg

User avatar

Joined: 26 Jun 2004
Gender: Male
Posts: 6

13 Jul 2004, 1:58 am

mic wrote:
Quote:
Are we talking about an expression evaluator that you give a string like say "3 * 2 + 5" and it comes back with a result

That type of calculator is what I mean.

Are you interested in solving this problem from a pragmatic point of view (that is, "how do you write an arithmetic expression evaluator with the least amount of effort?"), or from a theoretical point of view ("how do these things work?").

From a pragmatic point of view in C++, you would find some library that someone has already written and just use that. Some other languages have a built-in evaluator that you could use.

From a theoretical point of view, we are getting into parsing, and things start to get complicated ...



NooneInParticular
Emu Egg
Emu Egg

User avatar

Joined: 8 Jul 2004
Gender: Male
Posts: 4

13 Jul 2004, 12:04 pm

Writing an RPN (reverse polish notation) calculator is pretty easy in most langugages... parsing is handled by employing a simple LIFO-type data structure like a stack.

There is even hardware that uses LPN, namely HP calculators.




MoonPatrol wrote:
mic wrote:
Quote:
Are we talking about an expression evaluator that you give a string like say "3 * 2 + 5" and it comes back with a result

That type of calculator is what I mean.

Are you interested in solving this problem from a pragmatic point of view (that is, "how do you write an arithmetic expression evaluator with the least amount of effort?"), or from a theoretical point of view ("how do these things work?").

From a pragmatic point of view in C++, you would find some library that someone has already written and just use that. Some other languages have a built-in evaluator that you could use.

From a theoretical point of view, we are getting into parsing, and things start to get complicated ...



MoonPatrol
Emu Egg
Emu Egg

User avatar

Joined: 26 Jun 2004
Gender: Male
Posts: 6

15 Jul 2004, 4:18 pm

NooneInParticular wrote:
Writing an RPN (reverse polish notation) calculator is pretty easy in most langugages... parsing is handled by employing a simple LIFO-type data structure like a stack.

There is even hardware that uses LPN, namely HP calculators.

Yes, and a classic way of evaluating normal ("infix") arithmetic expression is to convert them to RPN (or "postfix") first. There's an algorithm out there to do this.



macvincent
Blue Jay
Blue Jay

User avatar

Joined: 31 Jul 2004
Gender: Male
Posts: 80

07 Aug 2004, 11:20 pm

I have written a calculator in PHP where you type in an expression and it solves it for you.

Once I tried writing a "button" calculator using html and javascript but it didn't work too well.



baseballfan
Tufted Titmouse
Tufted Titmouse

User avatar

Joined: 18 Aug 2004
Age: 43
Gender: Male
Posts: 44
Location: State College, PA, USA

26 Oct 2004, 11:17 pm

I created a calculator back in my high school CS1 days. By the way, you might want to change the topic to read: Have you "written" a calculator.



MishLuvsHer2Boys
Veteran
Veteran

User avatar

Joined: 8 Oct 2004
Age: 50
Gender: Female
Posts: 2,491
Location: Canada

27 Oct 2004, 6:51 am

I was never into programming but I had a cousin that did that. It was kinda neat.



Feste-Fenris
Veteran
Veteran

User avatar

Joined: 26 Oct 2004
Gender: Male
Posts: 520

27 Oct 2004, 8:35 pm

I once used BASIC to make a celsius farenheit converter...

So Farenheit 911 equals Celsius 450...

Bung!



Tom_FL_MA
Deinonychus
Deinonychus

User avatar

Joined: 4 Jul 2004
Age: 46
Gender: Male
Posts: 304
Location: Central Florida; originally southeastern Massachusetts

28 Oct 2004, 5:07 pm

Feste-Fenris wrote:
So Farenheit 911 equals Celsius 450...


911°F = 488°C

To convert Celsius to Fahrenheit: °F = 1.8 x °C + 32 | {9/5 = 1.80}

To convert Fahrenheit to Celsius: °C = °F - 32 x .555 | {5/9 = .555}


Here's how it's broken down: 1.8 x 488°C + 32 = 910.4°F, rounded to 911°F &
                                               911°F - 32 x .555 = 487.8°C, rounded to 488°C