Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
FOCAL (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Math === FOCAL contained five mathematical operators:{{sfn|Manual|1968|p=2.4}} * {{code|^}} for exponents β the exponent is converted to a 12-bit integer * {{code|*}} for multiplication * {{code|/}} for division * {{code|+}} for addition * {{code|-}} for subtraction One curiosity of the 1968 version of FOCAL was that the operators had independent precedence, as in the order above. Although this certainly applies to exponentiation, multiplication, and division, there is some ambiguity in the 1968 FOCAL manual with regards to addition and subtraction. Specifically, examples that demonstrate operator precedence for multiplication and division are provided, but examples demonstrating operator precedence for addition and subtraction are lacking. Nevertheless, the literal interpretation of the 1968 FOCAL manual suggests that the formula {{code|SET T{{=}}2-3+1}} would be evaluated in the order 2-(3+1) and thus produce -2. This was very different than most languages, where the + and - had equal precedence and would be evaluated (2-3)+1 to produce 0.{{sfn|Manual|1968|p=2.4}} This can cause subtle errors when converting FOCAL source code to other systems. However, the + and - have the same precedence in FOCAL-69 and FOCAL-71, so {{code|SET T{{=}}2-3+1}} yields 0, as expected. FOCAL was unusual in that mathematical expressions could use (), [], and <> interchangeably in matched pairs to establish precedence.{{sfn|Manual|1968|p=2.4}} For example, the following is a valid expression: 01.30 SET A=<10*[5+1]*(1+5)> All of these are the same level of precedence and read left-to-right when at the same level, so this statement will be evaluated [], then (), then <>, to produce 360.{{sfn|Manual|1968|p=2.4}} The language contained the following built-in functions:{{sfn|Manual|1968|p=3.10}} * {{code|FABS()}} β Absolute value * {{code|FATN()}} β Arctangent * {{code|FCOS()}} β Cosine of argument in radians * {{code|FEXP()}} β Natural base to the power of the argument * {{code|FITR()}} β Integer part of the argument * {{code|FLOG()}} β [[Napierian_logarithm|Naperian log]] * {{code|FRAN()}} β Random number * {{code|FSGN()}} β Sign of the argument; FSGN(0)=1 in FOCAL-69, but FSGN(0)=0 in FOCAL-71 and later versions * {{code|FSIN()}} β Sine of an angle given in radians * {{code|FSQT()}} β Square root
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)