Can I get a percent of number without using decimals? I am programming in a language that does not support decimal numbers. The language only supports positive or negative whole numbers. Is there a way to calculate the percent of a number only using whole numbers?
The language automatically rounds the number down in the case of a remainder. I.e. 97 / 33 = 2
I have two values:
The percent and the number I am trying to get the percent of.
For example, lets say I have the number 126,345 and I want to get 13 % of that number.
The result of that normally would be 16,424.85. If this is possible the language would cut off the .85 remainder which is fine.
Thanks for your time and help!
Somewhat related to the subject, here is an example of a floating-point division result using integer functions:
125 / 13 = 9  &lt;-
125 Mod 13 = 8
80 / 13 = 6  &lt;-
80 Mod 13 = 2
20 / 13 = 1  &lt;-
20 Mod 13 = 7
70 / 13 = 5  &lt;-
for 9.615 as 9.62 .
Or the actual problem: 126345 * 13 = 1642485; 1642485 / 100 = 16424; 1642485 Mod 100 = 85; 850 / 100 = 8; 850 Mod 100 = 50; 500 / 100 = 5; 500 Mod 100 = 0; 0 / 100 = 0;
for 16424.850 as 16424.85 .
As said by @magdiragdag in the comments, multiply by $13$ and then divide by $100$.
If your division rounds down (so that $160/100=1$) and you want to round to the nearest whole number instead, multiply by $13$, then add $50$, and then divide by $100$.