[m-users.] What's special about Mercury?
Zoltan Somogyi
zoltan.somogyi at runbox.com
Sun Jun 23 21:21:56 AEST 2019
On Sun, 23 Jun 2019 13:08:50 +1000, Peter Wang <novalazy at gmail.com> wrote:
> I would not push the multiple modes angle at all. If a reader tries to
> write even the feet to inches conversion as a multi-moded predicate,
> they would quickly find it doesn't work.
To clarify: this is not a limitation of Mercury so much as a limitation of arithmetic.
Consider X / Y = Z when X, Y and Z are all integers. If X = 5 and Y = 2, then obviously
Z = 2. But if the inputs are Y = 2 and Z = 2, then X can be either 4 or 5, so while
division is in principle invertible, it is not *uniquely* invertible (i.e. inverting does not
guarantee a unique result). Floating point division does not have this problem, but
has related issues caused by limited precision representations. And while division
over real numbers is uniquely invertible in the vast majority of cases, there are
exceptions: 0.0 / Y = 0.0 has an infinite number of solutions for Y.
Zoltan.
More information about the users
mailing list