Subject: modulus operator in c
To: None <current-users@NetBSD.ORG>
From: Andrew Brown <firstname.lastname@example.org>
Date: 01/22/1997 12:30:51
just a simple query, not necessarily related to netbsd although it
might be interesting to find out...
does anyone out there who compiles and runs this program
printf("%d %d %d %d\n",dividend,divisor,quotient,remainder);
-3 -2 1 -1
as output? any system at all, any os at all...i'm trying to find something
somewhere that does not. the reason stems from the k&r book's definition
on what the quotient and remainder will be from integer arithmetic. see
section A7.6, paragraph 4:
".... If both operands are non-negative, then the remainder is non-
negative and smaller than the divisor; if not, it is guaranteed only
that the absolute value of the remainder is smaller than the absolute
value of the divisor."
if anyone finds such a machine, please let me know...?
|-----< "CODE WARRIOR" >-----|
email@example.com (TheMan) * "ah! i see you have the internet
firstname.lastname@example.org that goes *ping*!"
email@example.com * "information is power -- share the wealth."