Jump to content

Arithmetic/Rational: Difference between revisions

→‎{{header|jq}}: allow rfloor input to be an integer
(→‎{{header|jq}}: allow rfloor input to be an integer)
Line 2,401:
end;
 
# Assume . is an integer or in canonical form
def rfloor:
if 0type == .n or (0 < .n and .n < .d)"number" then r(0.;1)
elif 0 == .n or (0 < .n and .n < .d) then r(0;1)
elif 0 < .n or (.n % .d == 0) then .d as $d | r(.n | idivide($d); 1)
else rminus( r( - .n; .d) | rfloor | rminus; 1)
2,465

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.