MySQL Forums
Forum List  »  Stored Procedures

Round error in store function
Posted by: Alejandro MS
Date: May 18, 2011 07:07AM

Hi
My name is Alejandro, i am working in a calculation function, this function ajust the % for task calculate.

This is the function :

CREATE FUNCTION MVA_Ajustada( MVAOriginal DECIMAL, ALQInter DECIMAL, ALQIntra DECIMAL )
RETURNS DECIMAL(6,3)
DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE nResult DECIMAL(6,3) DEFAULT 0.00;

SET nResult = ( ( 1 + MVAOriginal ) * ( ( 1 - ALQInter ) / ( 1 - ALQIntra ) ) ) - 1;

RETURN nResult;
END;

Runing this, returns 48
SELECT MVA_Ajustada( 48.01, 0.12, 0.17 );

Runing the this :
SELECT ( ( 1 + 48.01 ) * ( ( 1 - 0.12 ) / ( 1 - 0.17 ) ) ) - 1

returns 50.96240964

Why this?

Is the same sitution in both place, the same imput.

Can you give me some ligth?
Thanks in advance

Options: ReplyQuote


Subject
Views
Written By
Posted
Round error in store function
1974
May 18, 2011 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.