Subject Re: Firebird ROUND
Author Adam
You can create your own version of the round function using a UDF. I
am not sure / I could not find whether firebird already has this
function you are talking about.

If you are using Delphi, the main gotcha in creating your own round
function is that Delphi uses bankers rounding by default, where *.5
is rounded to the closest even number, not upwards as most people are
used to. You may want to use this function

function RoundCorrect(R: Real): LongInt;
begin
Result:= Trunc(R); // extract the integer part
if Frac(R) >= 0.5 then // if fractional part >= 0.5 then...
Result:= Result + 1; // ...add 1
end;


your function would look something like this

function MyRound(Value : Double; Prec : Integer) : Double;
begin
if Prec < 0 then Prec := 0;


Result := RoundCorrect(Power(10, Prec) * Value) / Power(10,
Prec);
end;


--- In firebird-support@yahoogroups.com, "Sebastian J."
<jsebastianb00@y...> wrote:
> Hi to everyone, I have a question... I need to round a decimal
number as I used to do in SQL Server for example:
>
> Select Round(6.3254, 2) as Value_Rounded From MyTable
>
> The result looks like this:
> -------
> 6.3300
>
>
> How can I do this in FB, I was using the FB_UDF but the ROUND
Function only acept 1 parameter and I can't pass the decimals number
that I wanna.
>
> Thanks a lot.....
>
> Regards, Antonio
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
>
> [Non-text portions of this message have been removed]