S
Sidney Cadot
Hi all,
As I understand it, the rounding direction of signed integer division
in C is unspecified in C89/C94, and specified to be 'towards-zero' in
C99.
I need division 'towards -infinity' (with a 'mod' operation to match),
i.e. for x and y I need to obtain D and M such that
(1) D*abs(y)+M == x
(2) 0 <= M<abs(y)
For any signed x,y (y!=0).
Is there a canonical way of doing this that is guaranteed to work in
line with all C specifications?
Best regards,
Sidney Cadot
The Netherlands
As I understand it, the rounding direction of signed integer division
in C is unspecified in C89/C94, and specified to be 'towards-zero' in
C99.
I need division 'towards -infinity' (with a 'mod' operation to match),
i.e. for x and y I need to obtain D and M such that
(1) D*abs(y)+M == x
(2) 0 <= M<abs(y)
For any signed x,y (y!=0).
Is there a canonical way of doing this that is guaranteed to work in
line with all C specifications?
Best regards,
Sidney Cadot
The Netherlands