Calculator glitch?

A place to discuss the science of computers and programs, from algorithms to computability.

Formal proofs preferred.

Moderators: phlip, Moderators General, Prelates

kirchnal
Posts: 1
Joined: Wed Dec 03, 2008 6:31 am UTC

Calculator glitch?

Postby kirchnal » Wed Dec 03, 2008 6:36 am UTC

I was twiddling around with my calculator (TI-86) the other day while bored in class and found that entering 0.Pi (the symbol Pi) returns 0 as an answer. I assumed this would be due to the lack of preprocessing of the pi symbol (since typing 0.3.1415 gives a syntax error) and it defaults to 0*Pi, but the same result happened when i typed in 0.(-1^0.5) (effectively, 0.i). Any thoughts on why this happens, instead of just giving a syntax error?

User avatar
mochafairy
Posts: 1098
Joined: Tue Mar 25, 2008 11:27 pm UTC
Location: Ohio

Re: Calculator glitch?

Postby mochafairy » Wed Dec 03, 2008 6:43 am UTC

I think your calculator is assuming that you mean "0 * pi" and "0 * i". I'm pretty sure it'd do the same thing if you tried 0.e
"YES. DO IT WITH CONFIDENCE" ~fortune cookie

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: Calculator glitch?

Postby Carnildo » Wed Dec 03, 2008 8:53 am UTC

kirchnal wrote:I was twiddling around with my calculator (TI-86) the other day while bored in class and found that entering 0.Pi (the symbol Pi) returns 0 as an answer. I assumed this would be due to the lack of preprocessing of the pi symbol (since typing 0.3.1415 gives a syntax error) and it defaults to 0*Pi, but the same result happened when i typed in 0.(-1^0.5) (effectively, 0.i). Any thoughts on why this happens, instead of just giving a syntax error?


I don't know for certain that this is how the calculator works, but here's what the calculator would be thinking if I'd designed it:

0 - It's a number part. I'll start figuring out what number it is.
. - Still a number part. Keep processing
π - Not a number part. I'm done with the last number - it's a zero! This isn't an operation, either, so the user must be doing an implicit multiplication. This looks like the start of a variable name.
end of input - Hey, that's Pi! I know what value that has! He's asking for 0 times 3.141592653589, which is 0.

Likewise, for 0.(-1^0.5)
0 - It's a number part. I'll start figuring out what number it is.
. - Still a number part. Keep processing
( - Not a number part. I'm done with the last number - it's a zero! This isn't an operation, either, so the user must be doing an implicit multiplication. This looks like grouping.
- - This is a negation operation. I'll keep that in mind.
1 - It's a number part! He's entering a number!
^ - Not a number part. The last number was a 1. This is an exponentiation opration. It's higher-priority than the negation operation, so I need to do this before I can do the negation.
0 - It's a number part! He's entering a number!
. - Still a number part.
5 - Still a number part.
) - Not a number. The last number must have been 0.5. This is an end-of-grouping, so I need to do every operation I've got queued up. First is exponentiation: 1 raised to 0.5 is 1. Next is negation: the negation of 1 is -1. I don't have anything else to do.
end of input - He's asking for 0 times -1: that's 0.

For 0.3.1415:
0 - It's a number part! He's entering a number.
. - Still a number part.
3 - Still a number part.
. - Still a number part. Hey! I've already got one of those! What's the meaning of this, you blockhead?

Hope this helps you understand why the calculator does what it does.

User avatar
Generic Protoplasm
Posts: 90
Joined: Wed Oct 17, 2007 2:49 am UTC

Re: Calculator glitch?

Postby Generic Protoplasm » Thu Dec 04, 2008 3:30 am UTC

It's thinking 0*pi, but you just have a decimal after the zero.

It's like you typed in the decimal to show that the first decimal place of 0 is a significant figure.

0. = 0
Life is like a rock candy, you never know which attribute you're gonna increase next.

ks_physicist
Posts: 230
Joined: Wed Jun 27, 2007 10:09 am UTC

Re: Calculator glitch?

Postby ks_physicist » Thu Dec 04, 2008 3:42 am UTC

I just tried it on a TI-85.

0.[pi] returns zero.

1.[pi] returns 3.141...

2.[pi] returns 6.283...

0.3.14159 returns SYNTAX ERROR, as it should.

So, it is seeing the "0." as zero point nothing, and "1." as one point nothing, and then behaving as if you had put in "0 [pi]" or "1 [pi]", where the multiplication is implied.

muffinmanpoo
Posts: 4
Joined: Thu May 24, 2007 12:26 pm UTC
Location: Melbourne, Australia

Re: Calculator glitch?

Postby muffinmanpoo » Wed Dec 10, 2008 5:09 am UTC

Carnildo wrote:I don't know for certain that this is how the calculator works, but here's what the calculator would be thinking if I'd designed it:


I love the way your calculator gets so excited! It's like, "Ooh! A number!"

charl.ie
Posts: 23
Joined: Sat Nov 08, 2008 8:41 pm UTC

Re: Calculator glitch?

Postby charl.ie » Wed Dec 10, 2008 7:24 pm UTC

muffinmanpoo wrote:
Carnildo wrote:I don't know for certain that this is how the calculator works, but here's what the calculator would be thinking if I'd designed it:


I love the way your calculator gets so excited! It's like, "Ooh! A number!"

I wish my calculator went through the steps with me like that. It would always brighten up my day.
Ten points to whoever can write a program to take a calculation and output something like that. Bonus points to be able to configure the text.

User avatar
mochafairy
Posts: 1098
Joined: Tue Mar 25, 2008 11:27 pm UTC
Location: Ohio

Re: Calculator glitch?

Postby mochafairy » Wed Dec 10, 2008 7:39 pm UTC

I'll see if I can whip up a matlab script that will do that and draw smilie faces over break...
"YES. DO IT WITH CONFIDENCE" ~fortune cookie


Return to “Computer Science”

Who is online

Users browsing this forum: No registered users and 6 guests