fix our math terms (thanks ubsan!)

This commit is contained in:
Lokathor 2018-12-16 00:59:36 -07:00
parent 1fcfbb00e8
commit fd681b182e

View file

@ -47,7 +47,7 @@ pub const fn rgb16(red: u16, green: u16, blue: u16) -> u16 {
/// If `denominator` is 0.
#[inline]
pub fn div(numerator: i32, denominator: i32) -> i32 {
div_modulus(numerator, denominator).0
div_rem(numerator, denominator).0
}
/// BIOS Call: Div (GBA SWI 0x06).
@ -58,19 +58,19 @@ pub fn div(numerator: i32, denominator: i32) -> i32 {
///
/// If `denominator` is 0.
#[inline]
pub fn modulus(numerator: i32, denominator: i32) -> i32 {
div_modulus(numerator, denominator).1
pub fn rem(numerator: i32, denominator: i32) -> i32 {
div_rem(numerator, denominator).1
}
/// BIOS Call: Div (GBA SWI 0x06).
///
/// Gives both the DIV and MOD output of `numerator / denominator`.
/// Gives both the DIV and REM output of `numerator / denominator`.
///
/// # Panics
///
/// If `denominator` is 0.
#[inline]
pub fn div_modulus(numerator: i32, denominator: i32) -> (i32, i32) {
pub fn div_rem(numerator: i32, denominator: i32) -> (i32, i32) {
assert!(denominator != 0);
#[cfg(not(test))]
{