Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfd992e

Browse files
author
Michael Meskes
committed
Fixed floating point exception in long=>numeric conversion.
1 parentd665217 commitcfd992e

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,10 @@ Mon Oct 6 08:41:45 CEST 2003
16791679
Tue Oct 7 07:45:09 CEST 2003
16801680

16811681
- Fixed error handling in rstrdate.
1682+
1683+
Tue Oct 7 20:26:06 CEST 2003
1684+
1685+
- Fixed floating point exception in long=>numeric transformation.
16821686
- Set ecpg version to 3.0.0
16831687
- Set ecpg library to 4.0.0
16841688
- Set pgtypes library to 1.0.0

‎src/interfaces/ecpg/pgtypeslib/numeric.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
13381338
signed longintextract;
13391339
signed longintreach_limit;
13401340

1341+
printf("l=%ld\n",long_val);
13411342
if (abs_long_val<0)
13421343
{
13431344
abs_long_val *=-1;
@@ -1351,10 +1352,19 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
13511352
{
13521353
size++;
13531354
reach_limit *=10;
1354-
}while ((reach_limit-1)<abs_long_val);
1355+
}while ((reach_limit-1)<abs_long_val&&reach_limit <=LONG_MAX/10);
13551356

1356-
/* always add a .0 */
1357-
size++;
1357+
if (reach_limit <=LONG_MAX/10)
1358+
{
1359+
/* add the first digit and a .0 */
1360+
size+=2;
1361+
}
1362+
else
1363+
{
1364+
/* always add a .0 */
1365+
size++;
1366+
reach_limit /=10;
1367+
}
13581368

13591369
if (alloc_var(var,size)<0)
13601370
return-1;
@@ -1366,11 +1376,11 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
13661376
i=0;
13671377
do
13681378
{
1369-
reach_limit /=10;
13701379
extract=abs_long_val- (abs_long_val %reach_limit);
13711380
var->digits[i]=extract /reach_limit;
13721381
abs_long_val-=extract;
13731382
i++;
1383+
reach_limit /=10;
13741384

13751385
/*
13761386
* we can abandon if abs_long_val reaches 0, because the memory is

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp