Subject Re: [firebird-support] Problem Using MOD
Author Paul Reeves
On Friday 18 July 2003 17:54, Nairo Granados wrote:
> Hi All,
>
> I'm using the function MOD in a stored procedure in Firebird 1.5 to
> get the remainder of a division but the operation get the wrong
> result.
>
> For Example
> A = MOD(2000, 19);
> The result is 105 instead of 5.
>
> I don't know why is this happen. Somebody could help me???
>

It looks as if your MOD function is returning the result of a division,
instead the modulus. However, the code in ib_udf is not quite as daft as
that. It really does want to return the modulus and a quick test shows that
it does -

SQL> select mod(2000,19) from rdb$database;

MOD
=======================

5.000000000000000

SQL> show ver;
ISQL Version: LI-T1.5.0.3549 Firebird 1.5 Release Candidate 3

So, are you quite sure that MOD is returning 105?


Paul
--
Paul Reeves
http://www.ibphoenix.com
Supporting users of Firebird and InterBase