Theiling Online    Sitemap    Conlang Mailing List HQ   

Re: Programming a calendar system

From:<jcowan@...>
Date:Wednesday, April 28, 2004, 16:52
Joe scripsit:

> >Exactly how you compute this depends on the language. In many C-like > >languages the type of the result of the '/' operator depends on the type > >of its operands, so 3296 / 60 = 54, but 3296.0 / 60.0 = 56.933333333 > >etc. In others the result of / is a float whenever the quotient is not > >exact, and you have to explicitly apply a function (usually "floor") > >to get integer form. > > Though not, of course, in C itself, which simply gives the answer as an > integer sans remainder.
Sort of. In C, i/j is the quotient rounded toward zero (truncated), and i%j is the remainder, except that it always has the same sign as i. So ((i/j) * j + i%j) == i is not an identity in C, because: ((10/-3) * -3) + 10%-3) == (-3 * -3) + 1 == -9 + 1 == -8 instead of -10. -- He made the Legislature meet at one-horse John Cowan tank-towns out in the alfalfa belt, so that jcowan@reutershealth.com hardly nobody could get there and most of http://www.reutershealth.com the leaders would stay home and let him go http://www.ccil.org/~cowan to work and do things as he pleased. --Mencken, Declaration of Independence