What\'s the easiest way to truncate a C++ float variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?
roundf(myfloat * powf(10, numDigits)) / powf(10, numDigits);
For example, in your case you're truncating three digits (numDigits). You'd use:
roundf(0.6000002 * 1000) / 1000
// And thus:
roundf(600.0002) / 1000
600 / 1000
0.6
(You'd probably store the result of powf somewhere, since you're using it twice.)
Due to how floats are normally stored on computers, there'd probably be inaccuracies. That's what you get for using floats, though.