lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am running on a Mac OS X 10.4.11 with lua 5.1.2, comiled in 2007.

here are the first few lines of output...

i:0.000000 r:0.000000 c:-0.000000 b:0.000000 br:-0.000000 bc:-0.000000
i:1.000000 r:0.000000 c:1.000000 b:0.000000 br:-0.000000 bc:1.000000
i:2.000000 r:0.000000 c:2.000000 b:0.000000 br:-0.000000 bc:2.000000
i:3.000000 r:0.000000 c:3.000000 b:1.000000 br:-0.000000 bc:-0.000000
i:4.000000 r:0.000000 c:4.000000 b:1.000000 br:-0.000000 bc:1.000000
i:5.000000 r:0.000000 c:5.000000 b:1.000000 br:-0.000000 bc:2.000000
i:6.000000 r:0.000000 c:6.000000 b:2.000000 br:-0.000000 bc:-0.000000
i:7.000000 r:0.000000 c:7.000000 b:2.000000 br:-0.000000 bc:1.000000
i:8.000000 r:0.000000 c:8.000000 b:2.000000 br:-0.000000 bc:2.000000
i:9.000000 r:1.000000 c:-0.000000 b:0.000000 br:1.000000 bc:-0.000000

As you notice, not all the 0's are negative. I don't know, maybe this
really isn't an issue, as so far I have not run into anything other
than this output being not exactly what I expect. I do know that I
have a later version of lua on my machine, but I don't really have the
time at the moment to check it... so maybe I should just try that and
then get back to the list...

Thanks for the help.

Mike

On Sun, Sep 19, 2010 at 12:33 PM, KHMan <keinhong@gmail.com> wrote:
> On 9/20/2010 12:19 AM, Mike McGonagle wrote:
>>
>> Well, here is the code that I am using, simplified to remove all the
>> tables...
>>
>> 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
>>
>> I would think that because all of the numbers that I am working with,
>> all the numbers would come out positive, but many of the resulting
>> '0's come out as -0. While I have tried to preliminary test to see if
>> "0 == -0", I am just wondering if by chance this is due to some
>> rounding error.
>
> Works fine on Lua 5.1.4/cygwin. Nothing negative.
>
> Time to check the platform and compiler.
>
> Do you have a sample line of output with the -0?
>
> --
> Cheers,
> Kein-Hong Man (esq.)
> Kuala Lumpur, Malaysia
>
>
>