Browse thread
[Caml-list] Integer arithmetic: mod
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Kai Kaminski <kok@w...> |
| Subject: | [Caml-list] Integer arithmetic: mod |
Hi, I have a question regarding the 'mod' operator in OCaml. While playing around with the toplevel, I found that -1 mod 10 = -1 instead of -1 mod 10 = 9. Looking into the Handbook showed me, that the behaviour of 'mod' is platform dependent for negative arguments. Now, I could live with -1 mod 10 = -1, but why is it platform-dependent? As far as I can see it would be better to specify a certain behaviour and emulate it on platforms, where it is not directly supported by the cpu, especially for a high-level language as OCaml. 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. Beside that the speed penalty (are there other problems with this approach?) would probably be not too bad, would it? On the other hand I'm just a student, who doesn't know too much about programming languages and their implementation. So could someone please enlighten me? 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