Round function which actually work.
I'm so stupid x( Thanks Lephé.
This commit is contained in:
parent
d40d6a5fb4
commit
7f72ba9dad
10
src/player.c
10
src/player.c
|
@ -186,12 +186,8 @@ f32 signf(f32 value) {
|
|||
}
|
||||
|
||||
i8 round(f32 value) {
|
||||
const i8 value_as_int = (i8)value;
|
||||
const f32 rest = value - (f32)(value_as_int * sign(value_as_int));
|
||||
if (rest >= 0.5)
|
||||
return value_as_int + 1;
|
||||
else if (rest <= -0.5)
|
||||
return value_as_int - 1;
|
||||
if (value > 0)
|
||||
return (i8)(value + 0.5);
|
||||
else
|
||||
return value_as_int;
|
||||
return (i8)(value - 0.5);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue