convert 0.54321 to 0.54 and convert 2 to 100
in
Programming Questions
•
2 years ago
- float test = 0.54321;
- test *= 100;
- test = int(test);
- test/=100;
- println(test);
This works, but is there a faster method?
And this gives me 2 decimals behind the .
I want a int:
int floatDecimals
to tell how many numbers after the comma are allowed.
So for this case,
int floatDecimals = 2;
but in my example it has to be 100.
So how can i convert 2 to 100? I know i can multiply it by 50... but that makes 3 150 where i want 3 to be 1000, 4 to be 10000...
1