Subject | Rounding problems |
---|---|
Author | Pirtea Calin |
Post date | 2002-05-16T13:38:08Z |
I've encountered a rounding problem with int64 numerics
using Delphi5 Pro and IBO4.2.Hc. When rounding 10.5 it results
10 witch is not ok for my client.
I've looked up the round definition from delphi help and
"If X is exactly halfway between two whole numbers,
the result is always the even number."
That is not acceptable. When X is exactly halfway
between two whole numbers, the result my client wants is always
the greater number. I don't have any other Delphi available to check
if round works the same but for me is definately a problem.
In IBO file IB_Utils function ExtendedToInt64 the last line does
Result := Round( AVal );
I've changed it to
if (Round( AVal )+0.5)=AVal then Result := Round( AVal )+1
else Result := Round( AVal );
in order to round always up when x=integer part +0.5
Is the normal behaviour of round wanted by the rest of you?
Or maybe this is the way you want it to work too?
Please state your opinion.
I just want to know if i'm alone on this or maybe is important for
others too.
TIA
--
Best regards,
Application Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@...
using Delphi5 Pro and IBO4.2.Hc. When rounding 10.5 it results
10 witch is not ok for my client.
I've looked up the round definition from delphi help and
"If X is exactly halfway between two whole numbers,
the result is always the even number."
That is not acceptable. When X is exactly halfway
between two whole numbers, the result my client wants is always
the greater number. I don't have any other Delphi available to check
if round works the same but for me is definately a problem.
In IBO file IB_Utils function ExtendedToInt64 the last line does
Result := Round( AVal );
I've changed it to
if (Round( AVal )+0.5)=AVal then Result := Round( AVal )+1
else Result := Round( AVal );
in order to round always up when x=integer part +0.5
Is the normal behaviour of round wanted by the rest of you?
Or maybe this is the way you want it to work too?
Please state your opinion.
I just want to know if i'm alone on this or maybe is important for
others too.
TIA
--
Best regards,
Application Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@...