Re: My problem in C
Give this a try:
#include <math.h>
// ...
if (val != (int)val) { // check for fractional part
float iptr;
float integral_part = modf(val, &iptr);
if (iptr > 0.5) {
val += 0.5;
} else if (iptr < -0.5) {
val -= 0.5;
}
}
It may not work on the else condition; the docs say:
C++ Reference (cppreference) wrote:
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
If arg is ±0, ±0 is returned, and ±0 is stored in *iptr.
If arg is ±8, ±0 is returned, and ±8 is stored in *iptr.
If arg is NaN, NaN is returned, and NaN is stored in *iptr.
The returned value is exact, the current rounding mode is ignored.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector