Author: wyoung
Date: Sat Mar 18 04:53:19 2006
New Revision: 1258
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1258&view=rev
Log:
Floating point insertions into database use maximum number of digits
guaranteed by IEEE 754 now. Previously, was using whatever the C++
library's default was. On Linux systems, this seems to be 6 digits, for
instance.
Modified:
branches/v2.1-bakefile/lib/query.h
branches/v2.1-bakefile/lib/sql_string.cpp
Modified: branches/v2.1-bakefile/lib/query.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/branches/v2.1-bakefile/lib/query.h?rev=1258&r1=1257&r2=1258&view=diff
==============================================================================
--- branches/v2.1-bakefile/lib/query.h (original)
+++ branches/v2.1-bakefile/lib/query.h Sat Mar 18 04:53:19 2006
@@ -41,6 +41,7 @@
#include <mysql.h>
#include <deque>
+#include <iomanip>
#include <list>
#include <map>
#include <set>
@@ -501,9 +502,9 @@
// Cast required for VC++ 2003 due to error in overloaded
operator
// lookup logic. For an explanation of the problem, see:
//
http://groups-beta.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
- dynamic_cast<std::ostream&>(*this) << "UPDATE " << o.table() <<
- " SET " << n.equal_list() << " WHERE " <<
- o.equal_list(" AND ", sql_use_compare);
+ dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ "UPDATE " << o.table() << " SET " <<
n.equal_list() <<
+ " WHERE " << o.equal_list(" AND ",
sql_use_compare);
return *this;
}
@@ -521,9 +522,10 @@
reset();
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << "INSERT INTO " <<
- v.table() << " (" << v.field_list() << ")
VALUES (" <<
- v.value_list() << ")";
+ dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ "INSERT INTO " << v.table() << " (" <<
+ v.field_list() << ") VALUES (" <<
+ v.value_list() << ')';
return *this;
}
@@ -549,9 +551,10 @@
}
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << "INSERT INTO " <<
- first->table() << " (" << first->field_list() <<
- ") VALUES (" << first->value_list() << ')';
+ dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ "INSERT INTO " << first->table() << " (" <<
+ first->field_list() << ") VALUES (" <<
+ first->value_list() << ')';
Iter it = first + 1;
while (it != last) {
@@ -578,9 +581,9 @@
reset();
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << "REPLACE INTO " <<
- v.table() << " (" << v.field_list() << ")
VALUES (" <<
- v.value_list() << ")";
+ dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ "REPLACE INTO " << v.table() << " (" <<
+ v.field_list() << ") VALUES (" <<
v.value_list() << ')';
return *this;
}
Modified: branches/v2.1-bakefile/lib/sql_string.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/branches/v2.1-bakefile/lib/sql_string.cpp?rev=1258&r1=1257&r2=1258&view=diff
==============================================================================
--- branches/v2.1-bakefile/lib/sql_string.cpp (original)
+++ branches/v2.1-bakefile/lib/sql_string.cpp Sat Mar 18 04:53:19 2006
@@ -26,6 +26,7 @@
#include "sql_string.h"
+#include <iomanip>
#include <sstream>
using namespace std;
@@ -141,6 +142,7 @@
processed(false)
{
ostringstream outs;
+ outs.precision(7); // max digits in IEEE 754 single-prec float
outs << f;
assign(outs.str());
}
@@ -151,6 +153,7 @@
processed(false)
{
ostringstream outs;
+ outs.precision(16); // max digits in IEEE 754 double-prec float
outs << f;
assign(outs.str());
}
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits