1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
"http://www.w3.org/TR/html4/strict.dtd"> |
3 |
<html> |
<html> |
4 |
<head> |
<head> |
5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
6 |
<title>Note on negative integer constants</title> |
<title>Note on negative integer constants</title> |
7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
<meta http-equiv="Content-Style-Type" content="text/css"> |
8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
9 |
</head> |
</head> |
10 |
<body> |
<body> |
11 |
|
|
12 |
<h1>Note on negative integer constants</h1> |
<h1>Note on negative integer constants</h1> |
13 |
|
|
14 |
<p> |
<p> |
15 |
Using a negative integer constant may cause a problem like the following: For example, |
Using a negative integer constant may cause a problem like the following: For example, |
16 |
</p> |
</p> |
17 |
|
|
18 |
<pre><code>for i -10 0</code></pre> |
<pre><code>for i -10 0</code></pre> |
19 |
|
|
20 |
<p> |
<p> |
21 |
causes the syntax error, because the second parameter is regarded as "i-10" instead of "i". To avoid this problem, take one of the following solutions: |
causes the syntax error, because the second parameter is regarded as "i-10" instead of "i". To avoid this problem, take one of the following solutions: |
22 |
</p> |
</p> |
23 |
|
|
24 |
<ol> |
<ol> |
25 |
<li>Put "0" before "-". |
<li>Put "0" before "-". |
26 |
<pre><code>for i 0-10 0</code></pre> |
<pre><code>for i 0-10 0</code></pre> |
27 |
</li> |
</li> |
28 |
|
|
29 |
<li>Assign the negative constant to a variable. |
<li>Assign the negative constant to a variable. |
30 |
<pre><code>A = -10 |
<pre><code>A = -10 |
31 |
for i A 0 |
for i A 0 |
32 |
</code></pre> |
</code></pre> |
33 |
</li> |
</li> |
34 |
</ol> |
</ol> |
35 |
|
|
36 |
</body> |
</body> |
37 |
</html> |
</html> |