What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[C#] Math Trouble!

Okay, in-depth here we go. BestX is the Best Possible Price Per Unit, after it has already calculated such, and bestZ is the best possible Discount percentage to assure top discount listing through all unit amounts on the website (a flaw in their website I exploit ;)). What I am trying to do is very simple, take BestX (The Price per Unit), multiply it by a number of units, in this case 2. Then subtract the Discount to show the final price.... it shouldn't be this complicated but no matter what formula I try it keeps giving me the wrong answers... :'(

BestX [7.47] * # Of Units [2] = 14.94
14.94 * BestZ [0.8] = 11.952
14.94 - 11.952 = Discounted Price [2.988]

Code:
var X = 7.47;
var Z = 0.8;
var ans = (X * 2) * (1 - Z); //== 11.952!?!?
var XA = 14.95;
var ZA = 0.8;
var ansA = XA * ([B]1 - ZA[/B]); // == 2.99!?!?!?!?

Which should be: Discount price = actualPrice * (1 - discountRate) -- .... BUT WON'T WORK :'(.

(1 - ZA)

1 - ZA =
1 - 0.8 = 0.2

0.8 = 80%
0.2 = 20%

to produce an 80% discount (which I assume is your aim), multiply by 0.2 which is the same as (1 - 0.8) 1 - ZA

double result2 = (bestX * numberOfUnits) * 0.2;
 
Last edited:
Back
Top