Click here to Skip to main content
15,894,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
decimal v1 = (test.rpmRequired);
           decimal v2 = test.rpmRequired * 14/100;
           decimal v3 = v1-v2;


What I have tried:

C#
decimal v1 = (test.rpmRequired);
           decimal v2 = test.rpmRequired * 14/100;
           decimal v3 = v1-v2;
Posted
Updated 26-Oct-16 23:45pm

1 solution

Probably, it's simple: stop using integers!
When you divide you integer values, you get an integer result - that then gets cast to a decimal value to multiply by the RPM. Since 14 is less than 100, 14/100 is 0 as an integer, so you always get zero as a result of the whole calculation.
Try adding an M suffix to all your constants to force them to be decimal values.

If that doesn't fix it, you need to tell us exactly what you expect, and what you are getting.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900