Fixed floating point exception in long=>numeric conversion.
This commit is contained in:
parent
d665217278
commit
cfd992ecba
@ -1679,6 +1679,10 @@ Mon Oct 6 08:41:45 CEST 2003
|
||||
Tue Oct 7 07:45:09 CEST 2003
|
||||
|
||||
- Fixed error handling in rstrdate.
|
||||
|
||||
Tue Oct 7 20:26:06 CEST 2003
|
||||
|
||||
- Fixed floating point exception in long=>numeric transformation.
|
||||
- Set ecpg version to 3.0.0
|
||||
- Set ecpg library to 4.0.0
|
||||
- Set pgtypes library to 1.0.0
|
||||
|
@ -1338,6 +1338,7 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
|
||||
signed long int extract;
|
||||
signed long int reach_limit;
|
||||
|
||||
printf("l=%ld\n", long_val);
|
||||
if (abs_long_val < 0)
|
||||
{
|
||||
abs_long_val *= -1;
|
||||
@ -1351,10 +1352,19 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
|
||||
{
|
||||
size++;
|
||||
reach_limit *= 10;
|
||||
} while ((reach_limit - 1) < abs_long_val);
|
||||
} while ((reach_limit - 1) < abs_long_val && reach_limit <= LONG_MAX/10);
|
||||
|
||||
/* always add a .0 */
|
||||
size++;
|
||||
if (reach_limit <= LONG_MAX/10)
|
||||
{
|
||||
/* add the first digit and a .0 */
|
||||
size += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* always add a .0 */
|
||||
size++;
|
||||
reach_limit /= 10;
|
||||
}
|
||||
|
||||
if (alloc_var(var, size) < 0)
|
||||
return -1;
|
||||
@ -1366,11 +1376,11 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
reach_limit /= 10;
|
||||
extract = abs_long_val - (abs_long_val % reach_limit);
|
||||
var->digits[i] = extract / reach_limit;
|
||||
abs_long_val -= extract;
|
||||
i++;
|
||||
reach_limit /= 10;
|
||||
|
||||
/*
|
||||
* we can abandon if abs_long_val reaches 0, because the memory is
|
||||
|
Loading…
x
Reference in New Issue
Block a user