Truncate Command?
in
Programming Questions
•
2 years ago
I saw this post
http://processing.org/discourse/yabb2/YaBB.pl?num=1224871364
and wanted it to be a bit more flexible…
Here's the updated code after addressing comments… thanks!
- float truncate(float x, int digits) {
- int d = (int)pow(10,digits);
- x *= d;
- x = int(x);
- x /= d;
- return x;
- }
1