mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:05:08 +00:00
LibM: Make roundf() and ceilf() slightly less terrible
These implementations still don't handle all of the corner cases that are possible, but at least they are somewhat usable now.
This commit is contained in:
parent
138abb9098
commit
570c6c8458
1 changed files with 10 additions and 4 deletions
|
@ -276,14 +276,20 @@ long double frexpl(long double, int*)
|
|||
|
||||
float roundf(float value)
|
||||
{
|
||||
// FIXME: Please fix me. I am sad.
|
||||
return (int)value;
|
||||
// FIXME: Please fix me. I am naive.
|
||||
if (value >= 0.0f)
|
||||
return (float)(int)(value + 0.5f);
|
||||
return (float)(int)(value - 0.5f);
|
||||
}
|
||||
|
||||
float ceilf(float value)
|
||||
{
|
||||
// FIXME: Please fix me. I am sad.
|
||||
return (int)value;
|
||||
// FIXME: Please fix me. I am naive.
|
||||
int as_int = (int)value;
|
||||
if (value == (float)as_int) {
|
||||
return (float)as_int;
|
||||
}
|
||||
return as_int + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue