From: Marcin 'Qrczak' Kowalczyk Date: 2003-01-05T06:19:29+09:00 Subject: Re: 1210 / 100 = 12? what? Fri, 27 Dec 2002 15:42:30 +0900, Brian Wisti pisze: > Integer division is one of those areas which is strangely > controversial. To some people, POLS is "integer divided by integer > results in an integer". To others, it is "a number divided by another > number results in the integer or decimal value to represent the precise > quotient, converting between numeric types if necessary". > > If you can't tell by my stumbling over the phrasing of this problem, I > belong in the first camp. Here is a different formulation. The second camp: the result of an arithmetic operation is defined by abstracting from the types, performing the operation on the mathematical values, and expressing the correct result in some type which fits. The first camp: as the first camp, except of one special case: division of integers. There not only the value matters, but also the type, and for integers it means something different than for floats (truncating division rather than real division). In a statically typed language it would not be a big flaw, because the meaning of an operation is known statically. Passing 5 to a function expecting a float performs the conversion. In Ruby it means that integers are substitutable for floats in all cases except division. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/