473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what does this statement mean?

Hi,
I came across this statement and it has a confusing element. I know the
whole '?:" construct and the assignment within the compare, but what's up
with the comma?

All the variables here are declared as doubles.

rtb = f < 0.0 ? (dx=x2-x1,x1) : (dx=x1-x2,x2)

Specifically, (dx=x2-x1,x1)? How do I read this?

Thanks!

Jay

Jul 23 '05 #1
2 2327
Comma can be used to separate expressions, the result of the overall
expression is the result of the last one. So...

If f is less than zero, then dx gets set to x2 minus x1, and then the
value of x1 is assigned to rtb.
Jul 23 '05 #2
Jay Wolfe wrote:
Hi,
I came across this statement and it has a confusing element. I know the
whole '?:" construct and the assignment within the compare, but what's up
with the comma?

All the variables here are declared as doubles.

rtb = f < 0.0 ? (dx=x2-x1,x1) : (dx=x1-x2,x2)

Specifically, (dx=x2-x1,x1)? How do I read this?


The whole line is equivalent to:

if (f < 0.0)
{
dx = x2 - x1;
rtb = x1;
}
else
{
dx = x1 - x2;
rtb = x2;
}

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
18799
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
125
14532
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
12
3269
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
121
9898
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
24
3762
by: David Mathog | last post by:
If this: int i,sum; int *array; for(sum=0, i=0; i<len; i++){ sum += array; } is converted to this (never mind why for the moment):
86
3837
by: Randy Yates | last post by:
In Harbison and Steele's text (fourth edition, p.111) it is stated, The C language does not specify the range of integers that the integral types will represent, except ot say that type int may...
669
25375
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
2005
by: riceyeh | last post by:
Hi, When reading the source code of dojo, it uses the following statement quite often. What does it mean? What I do not understand is it has a function definition enclosed in a pair of parenthesis...
18
2501
by: raghu | last post by:
hello, Iam going through a document contianing C tricks .In it they used the statement in many places i didn't understand can u please tell me the meaning and how the compiler compiles it and runs...
6
2114
by: raghu | last post by:
Hello This is raghu. And I want to know about the meaning of the statement given below log_txt( __FILE__, __LINE__, ##argList); in above statement what does FILE ,LINE ##argList mean. I want to...
0
7112
marktang
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,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
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,...
0
7356
tracyyun
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...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4878
isladogs
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...
0
4573
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...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.