Welcome! Enter your question below. Please use words like "Who, What, Where, When, Why, How, etc..." in your question. Nothing to ask? Click here for a random, un-answered question.

How do you perform arithmetic in tcsh?

1,070,045questions on
Add New Page
Talk0 Share

Integer arithmetic in tcsh can be done in expressions taken by "while", "if", "exit" or the assignment command "@". Floating point arithmetic is not built in.

Example (size of integer):

set i=0 j=1
while ($j)
  @ i++ j*=2
echo $i

Pay attention to the peculiar order of evaluation! If you type

> @ x = 1 - 1 + 1
> @ y = 2 * 1 / 2
> echo $x $y
-1 0

you probably mean:

> @ x = (1 - 1) + 1
> @ y = (2 * 1) / 2
> echo $x $y
1 1

The C shell by Bruce Barnett and General Electric Company

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.