Suppose I have a range from 0-100 & I choose a random number X say 29.
Now I increase the range to a big number say a 10-digit 1023654740.
Now I want to find the place of that X in 0-1023654740. (so that is I belive is 29% of 1023654740)
If I perform the calculation using Double, I’m getting an exponent value.
double range = 1023654740;
double position = 29; // Can be any number from 0 - range
Double val = (((double) position / range) * 100);
Result: 2.8329864422842414E-6
But I want final result in int.(dont care if the final value is rounded off or truncated)
Any suggestions
First, your calculation is wrong. According to your description, you probably want to do the following:
Then you can get your int value (by truncation) through: