Subject | Re: [firebird-support] MOD without UDF |
---|---|
Author | Markus Ostenried |
Post date | 2004-12-08T16:47:26Z |
At 17:23 Wednesday, 08.12.2004 +0100, Arn wrote:
try this:
CREATE PROCEDURE PROC_MODULUS( DIVIDEND INTEGER
, DIVISOR INTEGER )
RETURNS ( RESULT INTEGER )
AS
BEGIN
/* This procedure calculates the modulus of two numbers */
IF (Dividend = 0) THEN
Result = 0;
ELSE
Result = Dividend-(CAST((Dividend / Divisor)-0.49 AS INTEGER)*Divisor);
END
HTH,
Markus
>I need to perform a MOD operation in a procedure.Hi,
>
>Some time ago Ali Goken (Sp.?) ( Hi Ali) put in this list a way to do
>MOD without using UDF.
>
>Someone can recall this formula???
>Or know an equivalent one??
try this:
CREATE PROCEDURE PROC_MODULUS( DIVIDEND INTEGER
, DIVISOR INTEGER )
RETURNS ( RESULT INTEGER )
AS
BEGIN
/* This procedure calculates the modulus of two numbers */
IF (Dividend = 0) THEN
Result = 0;
ELSE
Result = Dividend-(CAST((Dividend / Divisor)-0.49 AS INTEGER)*Divisor);
END
HTH,
Markus