Skip to content

Float precision #471

@bloerwald

Description

@bloerwald

We are using a table containing floats, and have tests that use random values. The builtin serializers use std::ostringstream as underlying implementation, which defaults to std::ios_base::precision() == 6. This implies that values are quite quickly truncated.

A quick hack of

diff --git a/include/sqlpp11/sqlite3/connection.h b/include/sqlpp11/sqlite3/connection.h
index 79b3ae6..bd1a8ea 100644
--- a/include/sqlpp11/sqlite3/connection.h
+++ b/include/sqlpp11/sqlite3/connection.h
@@ -159,4 +159,5 @@ namespace sqlpp
       serializer_t(const connection& db) : _db(db), _count(1)
       {
+          _os.precision (std::numeric_limits<long double>::digits10 + 1);
       }

shows that the underlying implementation supports higher precision values without issue.

Was this an explicit design choice or are float values just so rare nobody noticed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions