mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-12 10:54:44 +00:00
Memstuff (#1164)
* Un-fake a couple of matches in memory manip functions * Document fmodf * Un-fake a couple of matches in memory manip functions * Document fmodf * Rename functions and files * Document memmove, memsets, memcpys * Format * Sort out some missing sizeofs * Name fmodf * Rename local variables * size_t * Use COBRA_SHADOW_TEX_SIZE * Review * Tweak the Doxyfile to remove @brief requirement * Roman's review * Fix a bug comment * Change fmodf
This commit is contained in:
parent
7334ffa373
commit
e84f5ab387
23 changed files with 282 additions and 208 deletions
|
@ -1,12 +1,27 @@
|
|||
#include "global.h"
|
||||
|
||||
/**
|
||||
* Computes one `x` modulo `y` for floats.
|
||||
*
|
||||
* Acts like the standard C fmodf except does not handle Infinity. See https://en.cppreference.com/w/c/numeric/math/fmod
|
||||
* for the details. It summarizes this function as follows:
|
||||
* "The floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y,
|
||||
* where n is x/y with its fractional part truncated.
|
||||
*
|
||||
* The returned value has the same sign as x and is less or equal to y in magnitude."
|
||||
*
|
||||
* @param x dividend
|
||||
* @param y modulus
|
||||
*
|
||||
* @return f32 0.0f if y is 0.0f, or x modulo y otherwise
|
||||
*/
|
||||
f32 fmodf(f32 x, f32 y) {
|
||||
s32 quot;
|
||||
s32 n;
|
||||
|
||||
if (y == 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
quot = x / y;
|
||||
n = x / y;
|
||||
|
||||
return x - (quot * y);
|
||||
return x - (n * y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue