integer division with float result

David B. Held dheld at codelogicconsulting.com
Tue Nov 20 22:15:50 PST 2007


Lars Noschinski wrote:
> * David B. Held <dheld at codelogicconsulting.com> [07-11-20 10:31]:
>> From a number theory perspective ints and floats are a world apart.  
>> It is true that integers are not a field because they are not closed 
>> under /.  However, that does not mean we should pretend that Z == R 
>> and force float opDiv(int, int).  The reality is that int != Z, 
>> either.  No, int == Z_2^32, and that *does* have a closed /, which 
>> makes it as much a field as R, and deserving of its own int opDiv(int, 
>> int).  Of course, the / defined on Z_n is different from int 
>> opDiv(int, int), but let us not concern ourselves with that minor detail.
> 
> Z_2^32 is not a field, and it has not got a division; e.g. 2^31 * z !=
> 1 for all z \in Z_2^32.

Ah, Z_p is only a field when p is prime...yes, that's a noob error.  I 
suspected as much, but I didn't work very hard to verify it.  Let's 
discard one of the bit patterns and say that int == Z_2^32-1. ;) 
Conceptually speaking, it's pretty close to true.

Dave



More information about the Digitalmars-d mailing list