Le 25/09/2013 02:55, Jesus a écrit :
> El 25/09/13 02:42, Benoît Minisini escribió:
>> Le 25/09/2013 01:23, Jesus a écrit :
>>> I've been racking my brain with a simple problem and I've discovered
>>> something weird with "Mod" operator, returning wrong results.
>>>
>>> For example, -3 Mod 800 gives -3, and it should be 797.
>>>
>>> It's only me or someone else has wrong results?
>>>
>>
>> See
>> http://en.wikipedia.org/wiki/Modulo_operation#Common_pitfalls
>>
>> -3 Mod 800 = -(3 Mod 800)
>>
>> This is not the mathematical modulus operator.
>>
>
> What is it, then? In Python, Modulus operator is % and gives the correct
> results. Also the calculator program has a Mod function which gives the
> expected result.
>
> Anyway I've made a function that mimics the Python modulus, so not a big
> problem.
>
> Thanks
>

I don't know Python, but the 'Mod' Gambas operator follow the behaviour 
of the '%' C operator. Maybe it was not a good idea.

Regards,

-- 
Benoît Minisini

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to