Hi folk, I have
u16 wTemp = 0; fsingle fTemp = 17.5123; wTemp = (u16)fTemp;
My understanding is: Rounding off should round to the nearest integer; Rounding down should round to the nearest integer below (ie, floor); Rounding up should round to the nearest integer above (ie, ceil) So: for positive values, truncation is equivalent to rounding down; for negative values, truncation is equivalent to rounding up; for negative values, you would round off by subtracting the 0.5.
So maybe he could do this:
int y = floatVar < 0.0 ? floor(floatVar) : ceil(floatVar);