MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / rem

Function rem

crates/virtual-machine/src/cpu/alu.rs:168–178  ·  view source on GitHub ↗

Signed remainder. Returns the dividend unchanged on divide-by-zero; 0 on overflow.

(a: u64, b: u64)

Source from the content-addressed store, hash-verified

166
167/// Signed remainder. Returns the dividend unchanged on divide-by-zero; 0 on overflow.
168pub fn rem(a: u64, b: u64) -> u64 {
169 let dividend = a as i64;
170 let divisor = b as i64;
171 if divisor == 0 {
172 a
173 } else if dividend == i64::MIN && divisor == -1 {
174 0
175 } else {
176 dividend.wrapping_rem(divisor) as u64
177 }
178}
179
180/// Unsigned remainder. Returns the dividend unchanged on divide-by-zero.
181pub fn remu(a: u64, b: u64) -> u64 {

Callers 1

exec_aluFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected