Hi,
I need to work with values that represent money, so I want to divide the input value by 100 and store it in int.
then do the calculations and result multiply by 100. (so I don't have to work with big decimal)
I just want to ask about the best way to parse float (initial value) to int
1:
float salary = 1254.93f;
float f = salary * 100;
int i = (int) f; // salary as integer
2:
String profit = (annualProfit < 0) ? "0.00" : String.format("%.2f", annualProfit);
int i = Integer.parseInt(profit.replace(".", "")); // salary as int