Reputation: 1667
As we know that we can convert any float or decimal point value to Integer value simply by using .toInt()
method.
But It converts 11.22 to 11 and 11.66 to 12 as I am doing ROUND.
This is absolutely fine.
But I have need of converting multi decimal value such as 0.1.1.12 to 0 0r 11.0.3.3 to 11.
In this case toInt()
giving NumberFormatException
How can I convert multi decimal point value to Int in easiest way ?
Upvotes: 0
Views: 310
Reputation: 137
That then would be a string and you should probably split it by finding the first dot and then converting the result at the [0] index to a int.
Upvotes: 1