2 * Copyright 2002-2010, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Daniel Reinhold, danielre@users.sf.net
7 * Tri-Edge AI, triedgeai@gmail.com
15 div(int numerator
, int denominator
)
19 val
.quot
= numerator
/ denominator
;
20 val
.rem
= numerator
% denominator
;
22 if (numerator
>= 0 && val
.rem
< 0) {
23 val
.rem
-= denominator
;
32 ldiv(long numerator
, long denominator
)
36 val
.quot
= numerator
/ denominator
;
37 val
.rem
= numerator
% denominator
;
39 if (numerator
>= 0 && val
.rem
< 0) {
40 val
.rem
-= denominator
;
49 lldiv(long long numerator
, long long denominator
)
53 val
.quot
= numerator
/ denominator
;
54 val
.rem
= numerator
% denominator
;
56 if (numerator
>= 0 && val
.rem
< 0) {
57 val
.rem
-= denominator
;