This function uses
Code: Select all
if (nScale > 0) // Multiply by 10
{
int nMultiplier = nScale * 10;
nReturn *= nMultiplier;
}
else if (nScale < 0) // Divide by 10
{
int nMultiplier = abs(nScale) * 10;
nReturn /= nMultiplier;
}
but if scale == 2 then 2 * 10 = 20 which will change the value completely.
This surely should be 10 to the power of nScale.
However, in the case of a Firebird decimal or numeric type which will usually have a scale indicating the number of digits to the right of the decimal point ( and a datatype of SQL_SHORT, SQL_LONG and either SQL_INT64 dialect 3 or DOUBLE PRECISION in dialect1 depending on specified precision) then the return value shouldn't be altered in the function at all because it returns a long data type and non integer data to the right of the decimal point will be lost.