FirebirdResultSet::GetResultLong Bug

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Experienced Solver
Experienced Solver
Posts: 74
Joined: Fri Nov 30, 2007 10:11 am
Location: Oz

FirebirdResultSet::GetResultLong Bug

Postby bone » Sat Apr 17, 2010 2:39 am

long FirebirdResultSet::GetResultLong(int nField)
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;

to scale the return value.
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.

Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 4 guests