assuming x is = 10.0
why after this assignment x becomes 210.0
x = x - 20.0
I appreciate the answer.
assuming x is = 10.0
why after this assignment x becomes 210.0
x = x - 20.0
I appreciate the answer.
Well, what's the variables type?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I'll assume that they are doubles scince u have the decimal.Originally posted by Absy
assuming x is = 10.0
why after this assignment x becomes 210.0
x = x - 20.0
I appreciate the answer.
I believe it would be
x = 190.0
Scince x was redefined as 210.0 you just subtract the 20.0 from that as the 10.0 is no longer in the equation.
I think Absy meant it became 210 AFTER the equation x=x-20.0
Somewhere between x=10.0 and x=x-20.0 you have code that is changing the value of x. Post all the code between these two statements and we'll help ya track it down!
Sorry if I confused you all,
Actually it was a question in one of the chapters Iread,and the question is like like this:
what value is assigned to x by the statement below assuming x is
10.0?
x = x - 20.0;
when I checked the answer at the end of the chapter it was
210.0
I just want to understand why is the answer like that and they did not mention what type the variable is or there is no more code lines thanks again.
I'm guessing the value loops back around...
eg.
unsigned char mychar = 0;
mychar -= 10;
mychar should now equal 245, as 255 is the max value for a char, and subtracting 10 from the min value (0) is going to give you 10 less than the max value. However, I can't think of any variable which has a max value of 220...
What book is this?
It's probably a typo, the answer is -10.0 The 2 was probably printed instead of the -
My Avatar says: "Stay in School"
Rocco is the Boy!
"SHUT YOUR LIPS..."
the book is " problem solving abstraction design using C++"
by frank l. friedman and elliot b. doffman
it is a text book in Penn State Univ. capitol campus
thanks for the reply
Yeah, tell this guy his book has a typo...
My Avatar says: "Stay in School"
Rocco is the Boy!
"SHUT YOUR LIPS..."