I'm now since a couple of weeks debugging a program and am now at the point where I don't know anymore what could be wrong (actually it compiles but does not do what I want)...
Anyway, if i want to write a=b*(c+d) and write the following code:
does the program what I want or does it see a=b*c+d?
I really hope it is the latter possibility, because that risks to solve my problem... thanks in advance either way
9 1161
I'm now since a couple of weeks debugging a program and am now at the point where I don't know anymore what could be wrong (actually it compiles but does not do what I want)...
Anyway, if i want to write a=b*(c+d) and write the following code:
does the program what I want or does it see a=b*c+d?
I really hope it is the latter possibility, because that risks to solve my problem... thanks in advance either way
It's same as a=a*(c+d) and becaue of a=b it is same as a=b*(c+d);
Savage
I'm now since a couple of weeks debugging a program and am now at the point where I don't know anymore what could be wrong (actually it compiles but does not do what I want)...
Anyway, if i want to write a=b*(c+d) and write the following code:
does the program what I want or does it see a=b*c+d?
I really hope it is the latter possibility, because that risks to solve my problem... thanks in advance either way
Does what you want it a = b * (c + d)
If you want it to be more readable you could just assign c+d to another variable and then do a *= var; That would produce the same results but maybe be a little more easy to read.
PS Savage beat me to it.
It's same as a=a*(c+d) and becaue of a=b it is same as a=b*(c+d);
Savage
So a*=c+d is equivalent to a*=(c+d) ?
EDIT: and you beat me to my answer to savage :)
Thanks very much both of you.
This code:
a=b;
a*=c+d;
is equivalent to:
This is a precedence issue. The *= operator has a precedence of 16 whereas addition has a precedence of 6. That means the addition is done before the *=.
Personally, I like your original method:
because it's easier to read.
Just thought that this precedence list
http://www.cppreference.com/operator_precedence.html
might help to justify why a*=c+d is equivalent to a=a*(b+c)
--Sorower
T
Personally, I like your original method:
because it's easier to read.
I agree that it easier to read, but if the b,c,d terms are very long (about one line) and the program is huge (260 MB of code) and you haven't written the program just modified it, which means that you might not know all the variables' names defined elsewhere and inherited to where you are, makes it difficult and risky to define for every b,c,d term a variables. So it leaves you no choice.
I would though never do it if it would be easily avoidable...
Also thanks about the explication of why via the precedences.
Just thought that this precedence list
http://www.cppreference.com/operator_precedence.html
might help to justify why a*=c+d is equivalent to a=a*(b+c)
--Sorower
Thanks, such a list clears up also some other things, bookm arked it right away.
Does what you want it a = b * (c + d)
If you want it to be more readable you could just assign c+d to another variable and then do a *= var; That would produce the same results but maybe be a little more easy to read.
PS Savage beat me to it.
Muhahahahahah
Savage
So a*=c+d is equivalent to a*=(c+d) ?
EDIT: and you beat me to my answer to savage :)
Thanks very much both of you.
We are more than happy to help u.
Savage
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Foord |
last post by:
#!/usr/bin/python -u
# 15-09-04
# v1.0.0
# auth_example.py
# A simple script manually demonstrating basic authentication.
# Copyright Michael Foord
# Free to use, modify and relicense.
#...
|
by: Malcolm |
last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC
interpreter.
The question is, how is it most useful?
At the moment I have a function
int basic(const char *script,...
|
by: Dave Vandervies |
last post by:
I just fixed a bug that some of the correctness pedants around here may
find useful as ammunition.
The problem was that some code would, very occasionally, die with a
segmentation violation...
|
by: luis |
last post by:
Are basic types (int, long, ...) objetcs or not?
I read that in C# all are objects including basic types, derived from Object
class. Then in msdn documentation says that boxing converts basic...
|
by: sefe dery |
last post by:
hi ng,
i try to create a asp.net 1.0 website on windows server 2003(Servername:
ServerX) with iis 6.0.
PROBLEM:
The user should login with his windows credentials in basic.aspx and...
|
by: usenet |
last post by:
How and where can one find out about the basics of VB/Access2003
syntax?
I am a died in the wool C/C++/Java Linux/Unix programmer and I am
finding it difficult to understand the program format...
|
by: trippeer |
last post by:
I have the source code to an old BASIC program that a friend of mine
would like to run online. I am a beginner at JS, but I think that it
would be a good choice for the project. My background is in...
|
by: Master Programmer |
last post by:
An friend insider told me that VB is to be killled off within 18
months. I guess this makes sence now that C# is here. I believe it and
am actualy surprised they ever even included it in VS 2003 in...
|
by: Enteng |
last post by:
Hi I'm thinking about learning C as my first programming language.
Would you recommend it?
Also how do you suggest that I learn it?What books/tutorials should I
read for someone like me?
Thanks...
|
by: Simon Walsh |
last post by:
I'm an Electronics student in college and I'm currently working on a
project. I was given a circuit diagram for my project, from which I had to
design a printed circuit board to be sent off and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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 project—planning, coding, testing,...
| |