is the above code i use correctly? because i dont get correct value!
1) ordergap*Point are points but what is PipValue - probably they don't match.
2) ordergap*Point*PipValue are e.g. $ - and value is it $ as well?
otherwise you 'compare apple with oranges'.
We don't know the value for PipValue.
We don't know what logic you are using or what you expect to achieve.
We don't know what value you get and what value you are expecting.
You need to give more details.
Your code is the same as
I can't see any problem with casting as Point is a double
This looks like a simple solution. The first thing you should do is, check whether the Math rules are set properly. Point calculation usually comes before adding and subtracting calculation. This is the first thing that I would look up. I would also put some parenthesis "(" and ")" around the Math, to make sure that your expected calculations are correct.
What do you calc here:
value + ordergap * Point * PipValue + newsgap * Point * PipValue
What is being added and what multiplicated ?
value + ( ordergap * Point ) * PipValue + ( newsgap * Point ) * PipValue
might return a different value than:
value + ordergap * ( Point * PipValue ) + newsgap * ( Point * PipValue )
Make sure you read yourself about operator priorities. That should solve the problem.
False. Multiplication has higher priority then addition A * B * C + D * E * F = (A * B) * C + (D * E) * F = A * (B * C) + D *( E * F) = (A * B * C) + (D * E * F)
You are right with what you explain. But that's not what I wanted to express in my initial reply. Though I might have chosen a better example.
As I tried to explain in my second reply, it depends on how the initial poster has made his calculus. It could be that the initial poster wasn't aware of the calculation rules or oversight that when doing his own calculus on dry run (e.g. on a piece of paper) and then afterwards tried bringing this in a formula.
He might have calculated
30 + 3 = 33
Summed up these values and later on multiplied it with a different value.
33 * 3 = 99
Then he might have taken these values into a formula and wondered why the result differs to those he initially calculated on paper:
30 + 3 * 3 = 39
Now he is sitting at home and can't figure out why the value 39 is not the expected sum of 99 that he initially tried to calculate... To whatever reasons...
Therefore I came up with the reference to operand priorities and the hint by using parenthesis in his calculations to give the stuff some priorities).
That might look as in our example like this:
(30 + 3) * 3 = 99
4 > 3 > 2
true > 2
1 > 2
To add comments, please log in or register