help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Precision of numbers writing Objective to Access Table


From: glpk xypron
Subject: Re: [Help-glpk] Precision of numbers writing Objective to Access Table
Date: Tue, 02 Nov 2010 23:17:23 +0100

Hello G√ľnther,

the rounding occurs in src/glpsql.c in the following statement
sprintf(num, "%-18g",mpl_tab_get_num(dca, k));

The CSV table driver uses
#include<float.h>
fprintf(csv->fp, "%.*g", DBL_DIG, mpl_tab_get_num(dca, k));

@Andrew
Could you, please, apply the following patch in the next release.

--- glpsql.c       2010-10-16 02:00:31.000000000 +0200
+++ glpsql.c       2010-11-02 23:13:36.000000000 +0100
@@ -959,7 +959,7 @@
       strcat( query, part );
       switch (mpl_tab_get_type(dca, k))
       {  case 'N':
-            sprintf(num, "%-18g",mpl_tab_get_num(dca, k));
+            sprintf(num, "%.18g", DBL_DIG, mpl_tab_get_num(dca, k));
             strcat( query, num );
             break;
          case 'S':
@@ -1571,7 +1571,7 @@
       strcat( query, part );
       switch (mpl_tab_get_type(dca, k))
       {  case 'N':
-            sprintf(num, "%-18g",mpl_tab_get_num(dca, k));
+            sprintf(num, "%.*g", DBL_DIG, mpl_tab_get_num(dca, k));
             strcat( query, num );
             break;
          case 'S':

Best regards

Xypron

-------- Original-Nachricht --------
> Datum: Tue, 2 Nov 2010 14:29:27 +0100
> Betreff: [Help-glpk] Precision of numbers writing Objective to Access Table

> 
> I am using the Access ODBC driver to write results back in an Access
> table.
> The correct objective is 1 990 638 880, which is rounded to 1 990 640 000
> 
> The SQL Update Statement is constructed like this:
> "UPDATE solScenario SET solScenario_objectiveValue = ? WHERE
> solScenario_id
> = ?" : Objective, id;
> 
> How can I avoid the this implicit rounding?

-- 
GMX DSL Doppel-Flat ab 19,99 &euro;/mtl.! Jetzt auch mit 
gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]