From c017c0ec7822c213d36bce6a575d025cc5bcea2a Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Tue, 14 May 2024 22:03:23 +0200 Subject: [PATCH] cheatsheet/sead: Add note about min/max --- docs/cheatsheet/common-inline-functions/sead.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/cheatsheet/common-inline-functions/sead.mdx b/docs/cheatsheet/common-inline-functions/sead.mdx index fca3509..bdd8221 100644 --- a/docs/cheatsheet/common-inline-functions/sead.mdx +++ b/docs/cheatsheet/common-inline-functions/sead.mdx @@ -6,6 +6,18 @@ sidebar_position: 0 sead is Nintendo's C++ standard library. It provides basic data structures such as strings and tree maps and many other essential components (e.g. threads, critical sections, file IO, etc.) +## Math + +### min/max functions + +When dealing with fmin/fmax instructions, pay close attention to the exact instruction and their order of operands. If the order of operands is wrong, try swapping the arguments of the call to the respective function call. + +When calculating the minimum of two floating point operands, either the instruction `fmin` or `fminnm` can be used by the compiler. The former is usually generated by `sead::Mathf::maxClamp`, while `fminnm` is generated by `sead::Mathf::min`. Both of these will show up as `fminf` in the pseudocode. + +```cpp +fmin => sead::Mathf::maxClamp +fminnm => sead::Mathf::min +``` ## Strings