In my Absolute Beginner's Guide to C book by Greg Perry
where it is instruction how relational operators work it gives the
following example:
int i = 5;
so the following statement is true:
int i == 1
Um, to me that says integer i is 5, and 5 is equal to 1.
Can someone help me understand this?
Thanks
Mar 4 '07
14 2573
August Karlstrom said:
Ben Pfaff skrev:
>August Karlstrom <fu********@com hem.sewrites:
>>Ben Pfaff skrev: == is not a relational operator (it is an equality operator) Of course it is -- in the same sense as a car is a vehicle. Other relational operators are <= and >=.
Not in C.
<proof snipped>
>
Laughable
Not at all. The relational operators test an ordering - a relation -
between two objects. == doesn't do that. It tests only whether two
objects are equal, and yields no relational information whatsoever.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Ben Pfaff wrote:
August Karlstrom <fu********@com hem.sewrites:
>Ben Pfaff skrev:
>>== is not a relational operator (it is an equality operator)
Of course it is -- in the same sense as a car is a vehicle. Other relational operators are <= and >=.
Not in C.
6.5.8 Relational operators
Syntax
1 relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
6.5.9 Equality operators
Syntax
1 equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
The reason being that the two kinds need separating, since you can
use equality operators on any two pointers, but not necessarily
relational operators.
--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Richard Heathfield wrote:
August Karlstrom said:
>Ben Pfaff skrev:
>>August Karlstrom <fu********@com hem.sewrites:
Ben Pfaff skrev: == is not a relational operator (it is an equality operator) Of course it is -- in the same sense as a car is a vehicle. Other relational operators are <= and >=. Not in C.
<proof snipped>
>Laughable
Not at all. The relational operators test an ordering - a relation -
between two objects. == doesn't do that. It tests only whether two
objects are equal, and yields no relational information whatsoever.
... and on a more practical level, the equality operators
can be used in situations where the relational operators would
produce undefined behavior:
int this;
char whatnot[97];
int that;
if (&this == &that) ... /* valid, false */
if (&this < &that) ... /* undefined behavior */
The two kinds of operators behave differently, so the
difference between them is not in the least "laughable. "
--
Eric Sosman es*****@acm-dot-org.invalid
Richard Heathfield skrev:
August Karlstrom said:
>Ben Pfaff skrev:
>>August Karlstrom <fu********@com hem.sewrites:
Ben Pfaff skrev: == is not a relational operator (it is an equality operator) Of course it is -- in the same sense as a car is a vehicle. Other relational operators are <= and >=. Not in C.
<proof snipped>
>Laughable
Not at all. The relational operators
in C terminology
test an ordering - a relation -
between two objects.
Exactly, these are *order* relations.
== doesn't do that.
It tests only whether two
objects are equal, and yields no relational information whatsoever.
Correct, equality is not an order relation.
Generally, if x and y are elements of the set M, a relation between x
and y is defined as a subset of M^2 (Cartesian product). So equality is
obviously a relation.
What's laughable is using the term relation but without letting equality
be an instance of it. They should have used a different name for the
order relations and the shift expressions.
August
August Karlstrom <fu********@com hem.sewrites:
[...]
Generally, if x and y are elements of the set M, a relation between x
and y is defined as a subset of M^2 (Cartesian product). So equality is
obviously a relation.
What's laughable is using the term relation but without letting equality
be an instance of it. They should have used a different name for the
order relations and the shift expressions.
Yeah, and a "byte" should be exactly 8 bits, and an "object" should be
something with methods and inheritance, and a "string" should be a
data type.
The authors of the standard had to express technical concepts using
English words, introducing explicit definitions where necessary. They
may not have done a perfect job of picking the best term in each
instance, but IMHO, they did pretty well. Referring to <, <=, >, and
>=, but not == and !=, as "relational operators", just doesn't bother
me that much.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Benson |
last post by:
Hi, I've been looking at the "Oracle9 i Database New Features" guide, from
which I quote:
XML Generation
In response to the challenge of generating XML in bulk from a database, XML
generation capabilities have been moved into the database and application
server
kernels and made available as built-in SQL operators. The kernel proximity
of these
operators ensures massively sustainable throughputs, enough for the largest
|
by: Balaji |
last post by:
Dear Jeff,
Thanks for your reply. I see that the PEP and the current docs
specify that __ge__ and __le__ are their own reflection.
Given that PEP 207 proposes rich comparison to handle cases
(brought upon by NumPy) where the objects returned should not be
assumed to be boolean, what is the argument for automatic reflection?
Automatic reflection prevents the resulting objects from being
|
by: glen herrmannsfeldt |
last post by:
The subject recently came up in comp.compilers, though I believe that
I asked here before.
If you use relational operators, other than == and !=, on
pointers to different objects, is there any requirement on
the result?
#include <stdio.h>
int main() {
|
by: Greenhorn |
last post by:
Hi,
Those relational operators have operands of all numerical type
int,char,float etc.
They also are working for character arrays. Whats the logic behind
their working. Is the length of the array compared first and then each
character compared with corresponding character.
{
const char msg = "msessage}", ch = "Za";
|
by: raju |
last post by:
hi
can we compare two integers without using relational operators (== != <
<= > >=)
thanks
rajesh s
| |
by: Robert Abi Saab |
last post by:
Hi everyone. I just finished a course on PostgreSQL and I found out that
PostgreSQL doesn't provide any object relational features (as claimed in
the official documentation), except table inheritance and very limited
user defined types (I defined a UDT with 2 attributes and couldn't use
it in a table, and the trainer said it must contain 1 attribute at most
so that it can be used (as a column) in tables)
So my question is whether...
|
by: jsparks57 |
last post by:
I want to cin two characters for any of the six relational operators.
'>=' no problem or '!=' no problem.
The problem is for reading single character '<' and '>'.
My code wants to read two characters but what works for a second character
for a single character relational operator.
The blank character ' ' is not accepted.
Maybe I should define '<' as '<,' or '<.' to get a simulated second character
for cin to accept?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |