Skip to content

Commit

Permalink
LibM: Add remainder{f, l}
Browse files Browse the repository at this point in the history
These just forward their arguments to fmod, but I think that should be
fine.
  • Loading branch information
RealKC authored and awesomekling committed Mar 14, 2021
1 parent e4197b7 commit 32b9437
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Userland/Libraries/LibM/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,22 @@ float fmodf(float index, float period) NOEXCEPT
return index - trunc(index / period) * period;
}

// FIXME: These aren't exactly like fmod, but these definitions are probably good enough for now
long double remainderl(long double x, long double y) NOEXCEPT
{
return fmodl(x, y);
}

double remainder(double x, double y) NOEXCEPT
{
return fmod(x, y);
}

float remainderf(float x, float y) NOEXCEPT
{
return fmodf(x, y);
}

long double expl(long double exponent) NOEXCEPT
{
long double res = 0;
Expand Down
3 changes: 3 additions & 0 deletions Userland/Libraries/LibM/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ float fabsf(float) NOEXCEPT;
long double fmodl(long double, long double) NOEXCEPT;
double fmod(double, double) NOEXCEPT;
float fmodf(float, float) NOEXCEPT;
long double remainderl(long double, long double) NOEXCEPT;
double remainder(double, double) NOEXCEPT;
float remainderf(float, float) NOEXCEPT;
long double nanl(const char*) NOEXCEPT;
double nan(const char*) NOEXCEPT;
float nanf(const char*) NOEXCEPT;
Expand Down

0 comments on commit 32b9437

Please sign in to comment.