Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Integer arithmetic: mod
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kai Kaminski <kok@w...>
Subject: Re: [Caml-list] Integer arithmetic: mod
On Mon, Aug 06, 2001 at 09:35:15AM +1000, John Max Skaller wrote:
> > The reason is that whenever such a behaviour is platform-dependent, you
> > can't use it at all, as long as you want to have your programs portable.
> 
> 	Yes you can: it works for non-negative arguments.
> And you can always roll your own function that works as you desire
> for negative ones:
I'm using a high-level language like OCaml and I still have to define my
own 'mod'-operator? I know that it is possible to write a function that
gives me what I want.

> This way, YOU choose whether you want a deterministic result
> for non-negative values (use mod, its fast), or are willing
> to pay extra for determinism for negative values.
With a second operator this wouldn't be a problem. If you need really
fast code and the behaviour for negative numbers doesn't matter, you
just choose the faster one. Your code gets a bit platform specific, but
it is better to 'punish' the few implementors of speed-critical
applications, than all the rest of us.

> But I agree with you anyhow. :-)
IMHO, that's always a good thing ;)

Kai Kaminski
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr