Created
April 20, 2013 06:39
-
-
Save kt3k/5425013 to your computer and use it in GitHub Desktop.
div implementation in ALGOL60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer procedure div(a, b); value a, b; | |
integer a, b; | |
if b = 0 then | |
fault( `div by zero' , a) | |
else | |
begin integer q, r; | |
q := 0; r := iabs(a); | |
for r := r - iabs(b) while r ≥ 0 do q := q + 1; | |
div := if a < 0 ≡ b > 0 then -q else q | |
end div; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment