Question:
What is syntax? Or a syntax error on a calculator?
NoExpense
2010-01-18 16:12:39 UTC
Im not sure what it is so I hope im right when I use this example. If you were to do something like 1 divided by 0 or enter 99999999+1 on a calculator you would get a syntax error because the calculator was no programmed to do so. Just because the user is not fallowing a certain protocol or set of rules set by the calculator it will get an error? I'm trying to get a basic idea, I know there might be more to the word but again, i'm still not sure.
Four answers:
Digitalhigh
2010-01-18 16:18:42 UTC
No, that's correct.



Think of it like this...the numbers are the calculator's words. The syntax is the sentence you're saying to it. If you say something it can't understand, you get a syntax error.



Same with computers. Instead of numbers, it's commands or a programming language. In programming, syntax is the method in which commands are passed to the interpreter. If the syntax isn't formatted just right, the programming won't work.
cen
2010-01-18 16:24:40 UTC
When you receive a syntax error on the calculator, it usually indicates that you either made a typographical error or tried to perform an operation in such a way that the calculator does not understand it or does not have an algorithm to use to compute it.



1 divided by 0 is an interesting example though. Even though your syntax was, in fact, correct (you pressed a number key, then the division key, and then another number key), the operation is not possible to compute.



It would actually be more correct for the calculator to give you a "Does not compute" error or something, rather than a syntax error.



As for 99999999+1, there's not really a problem with the syntax there either, it's just that the calculator probably doesn't have enough room to display that many digits on the screen at once.



A real syntax error might be something like this: 100 + + 1



That's an ambiguous expression. Reading that, you're not really sure of how to compute it, and neither is the calculator. I broke syntax there. I broke the rules governing how we represent mathematical expressions.



A real syntax error occurs when you do not express yourself clearly. It's the same in mathematics as it is in language, if that makes a better analogy.
oops
2010-01-18 16:24:04 UTC
Usually, things like the examples you provided are not considered syntax errors, those are overflow errors.



A syntax error is something like this:

100+*



or this:



50 * (20 + 3(



It's a statement that the calculator can't evaluate because it doesn't make sense(according to the calculator's or the computer's rules, which usually sync up with regular math)
Neil E
2010-01-18 16:17:54 UTC
A syntax error is generally when the computer/device doesn't understand the command you giving it. The examples you gave are "divide by zero" and "overflow" errors.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...