  lua-l archive

• Subject: Re: Why do some math functions return -0
• From: David Kastrup <dak@...>
• Date: Mon, 20 Sep 2010 12:01:26 +0200

```Tony Finch <dot@dotat.at> writes:

> On 20 Sep 2010, at 09:18, David Kastrup <dak@gnu.org> wrote:
>
>
>     Tony Finch <dot@dotat.at> writes:
>
>
>
>         It can happen if the rounding mode is towards negative
>         infinity.
>
>
>     Please point out the line in question where this would apply.
>
>
> There are lots of subtractions in the code.

Hogwash.  Here is the code again:

order = 3
elements = order * order
size = elements * elements

for i = 0, (size - 1) do
r = math.floor(i / elements)
c = math.floor(i % elements)
b = math.floor(math.floor(math.floor(r / order) * order) +
math.floor(c / order))
br = math.floor(r % order)
bc = math.floor(c % order)
print(string.format("i:%f r: %f c: %f b:%f br:%f bc:%f", i, r,
c,  b, br, bc))
end

The only subtraction is (size-1), and that is 80 rather than 0-.

> It would be nice if you could try to help instead of flaming.