Re: remainder() is not right

new topic     » goto parent     » topic index » view thread      » older message » newer message

I've added mod() to the standard library

global function mod(atom x, atom y)
    return x - y * floor(x / y)
end function


The test cases all pass:

test_equal("mod() #1",  3573, mod(-27, 3600))
test_equal("mod() #2",  3573, mod(-3627, 3600))
test_equal("mod() #3",   -27, mod(-3627, -3600))
test_equal("mod() #4", -3573, mod(27, -3600))
test_equal("mod() #5",     0, mod(10, 2))


Should I add any other tests to test for any strange parameters?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu