mirror of
https://github.com/italicsjenga/gba.git
synced 2025-01-11 11:31:31 +11:00
fix our math terms (thanks ubsan!)
This commit is contained in:
parent
1fcfbb00e8
commit
fd681b182e
10
src/lib.rs
10
src/lib.rs
|
@ -47,7 +47,7 @@ pub const fn rgb16(red: u16, green: u16, blue: u16) -> u16 {
|
||||||
/// If `denominator` is 0.
|
/// If `denominator` is 0.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn div(numerator: i32, denominator: i32) -> i32 {
|
pub fn div(numerator: i32, denominator: i32) -> i32 {
|
||||||
div_modulus(numerator, denominator).0
|
div_rem(numerator, denominator).0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// BIOS Call: Div (GBA SWI 0x06).
|
/// BIOS Call: Div (GBA SWI 0x06).
|
||||||
|
@ -58,19 +58,19 @@ pub fn div(numerator: i32, denominator: i32) -> i32 {
|
||||||
///
|
///
|
||||||
/// If `denominator` is 0.
|
/// If `denominator` is 0.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn modulus(numerator: i32, denominator: i32) -> i32 {
|
pub fn rem(numerator: i32, denominator: i32) -> i32 {
|
||||||
div_modulus(numerator, denominator).1
|
div_rem(numerator, denominator).1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// BIOS Call: Div (GBA SWI 0x06).
|
/// 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
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// If `denominator` is 0.
|
/// If `denominator` is 0.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn div_modulus(numerator: i32, denominator: i32) -> (i32, i32) {
|
pub fn div_rem(numerator: i32, denominator: i32) -> (i32, i32) {
|
||||||
assert!(denominator != 0);
|
assert!(denominator != 0);
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue