[M3devel] integer division rounding?

Mika Nystrom mika at async.async.caltech.edu
Mon Jan 18 02:59:59 CET 2010


Jay K writes:
>--_80188ab7-0cb8-4a34-8b91-f5a76ee2640e_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>
>Modula-3 apparently specifies integer division as rounding down.
>http://www.modula3.com/cm3/doc/reference/arithmetic.html
>
>C used to leave it unspecified. So it could be fast.
>Fortran rounded to zero.
>C's ldiv function rounds to zero.
>C now rounds to zero with C99.
>  The rationale was that nobody using Fortran seemed to mind.
>Java apparently rounds toward zero.
>C# apparently rounds toward zero.
>
>
>I'm assuming we are stuck being different here?
>
> - Jay
>

This is because Modula-3 has MOD while C has "remainder" (%).

If you use the normal definition of MOD you're stuck with making
DIV match it I think...

    Mika



More information about the M3devel mailing list