source: public/doc/gnu-c/Numeric-Comparisons.html@ 02598c2

Last change on this file since 02598c2 was 02598c2, checked in by Mikhail Kirillov <w96k@…>, on Oct 6, 2022 at 12:36:29 PM

Add gnu-c

  • Property mode set to 100644
File size: 5.2 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 2022 Richard Stallman and Free Software Foundation, Inc.
4
5(The work of Trevis Rothwell and Nelson Beebe has been assigned or
6licensed to the FSF.)
7
8Permission is granted to copy, distribute and/or modify this document
9under the terms of the GNU Free Documentation License, Version 1.3 or
10any later version published by the Free Software Foundation; with the
11Invariant Sections being "GNU General Public License," with the
12Front-Cover Texts being "A GNU Manual," and with the Back-Cover
13Texts as in (a) below. A copy of the license is included in the
14section entitled "GNU Free Documentation License."
15
16(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
17modify this GNU manual. Buying copies from the FSF supports it in
18developing GNU and promoting software freedom." -->
19<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
20<head>
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<title>Numeric Comparisons (GNU C Language Manual)</title>
23
24<meta name="description" content="Numeric Comparisons (GNU C Language Manual)">
25<meta name="keywords" content="Numeric Comparisons (GNU C Language Manual)">
26<meta name="resource-type" content="document">
27<meta name="distribution" content="global">
28<meta name="Generator" content="makeinfo">
29<link href="index.html" rel="start" title="Top">
30<link href="Symbol-Index.html" rel="index" title="Symbol Index">
31<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
32<link href="Arithmetic.html" rel="up" title="Arithmetic">
33<link href="Shift-Operations.html" rel="next" title="Shift Operations">
34<link href="Division-and-Remainder.html" rel="prev" title="Division and Remainder">
35<style type="text/css">
36<!--
37a.summary-letter {text-decoration: none}
38blockquote.indentedblock {margin-right: 0em}
39div.display {margin-left: 3.2em}
40div.example {margin-left: 3.2em}
41div.lisp {margin-left: 3.2em}
42kbd {font-style: oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47span.nolinebreak {white-space: nowrap}
48span.roman {font-family: initial; font-weight: normal}
49span.sansserif {font-family: sans-serif; font-weight: normal}
50ul.no-bullet {list-style: none}
51-->
52</style>
53
54
55</head>
56
57<body lang="en">
58<span id="Numeric-Comparisons"></span><div class="header">
59<p>
60Next: <a href="Shift-Operations.html" accesskey="n" rel="next">Shift Operations</a>, Previous: <a href="Division-and-Remainder.html" accesskey="p" rel="prev">Division and Remainder</a>, Up: <a href="Arithmetic.html" accesskey="u" rel="up">Arithmetic</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
61</div>
62<hr>
63<span id="Numeric-Comparisons-1"></span><h3 class="section">6.6 Numeric Comparisons</h3>
64<span id="index-numeric-comparisons"></span>
65<span id="index-comparisons"></span>
66<span id="index-operators_002c-comparison"></span>
67<span id="index-equal-operator"></span>
68<span id="index-not_002dequal-operator"></span>
69<span id="index-less_002dthan-operator"></span>
70<span id="index-greater_002dthan-operator"></span>
71<span id="index-less_002dor_002dequal-operator"></span>
72<span id="index-greater_002dor_002dequal-operator"></span>
73<span id="index-operator_002c-equal"></span>
74<span id="index-operator_002c-not_002dequal"></span>
75<span id="index-operator_002c-less_002dthan"></span>
76<span id="index-operator_002c-greater_002dthan"></span>
77<span id="index-operator_002c-less_002dor_002dequal"></span>
78<span id="index-operator_002c-greater_002dor_002dequal"></span>
79<span id="index-truth-value"></span>
80
81<p>There are two kinds of comparison operators: <em>equality</em> and
82<em>ordering</em>. Equality comparisons test whether two expressions
83have the same value. The result is a <em>truth value</em>: a number that
84is 1 for &ldquo;true&rdquo; and 0 for &ldquo;false.&rdquo;
85</p>
86<div class="example">
87<pre class="example">a == b /* <span class="roman">Test for equal.</span> */
88a != b /* <span class="roman">Test for not equal.</span> */
89</pre></div>
90
91<p>The equality comparison is written <code>==</code> because plain <code>=</code>
92is the assignment operator.
93</p>
94<p>Ordering comparisons test which operand is greater or less. Their
95results are truth values. These are the ordering comparisons of C:
96</p>
97<div class="example">
98<pre class="example">a &lt; b /* <span class="roman">Test for less-than.</span> */
99a &gt; b /* <span class="roman">Test for greater-than.</span> */
100a &lt;= b /* <span class="roman">Test for less-than-or-equal.</span> */
101a &gt;= b /* <span class="roman">Test for greater-than-or-equal.</span> */
102</pre></div>
103
104<p>For any integers <code>a</code> and <code>b</code>, exactly one of the comparisons
105<code>a &lt; b</code>, <code>a == b</code> and <code>a &gt; b</code> is true, just as in
106mathematics. However, if <code>a</code> and <code>b</code> are special floating
107point values (not ordinary numbers), all three can be false.
108See <a href="Special-Float-Values.html">Special Float Values</a>, and <a href="Invalid-Optimizations.html">Invalid Optimizations</a>.
109</p>
110
111
112
113</body>
114</html>
Note: See TracBrowser for help on using the repository browser.