Hello Tommi,

I was wondering if it might also be useful to add support
for decimal floating-point numbers to tntdb.  However
support for decimal floating point has not yet been standardized
in C and C++, although this is being worked on:

Extension for the programming language C++ to support decimal
floating-point arithmetic
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2198.pdf

MySQL 5.1, Oracle and PostgreSQL support decimal numbers
(in the SQL numeric and decimal types).  For SQLite, I
guess decimal numbers would have to be stored as double binary
floating point if they have a fractional component (or otherwise
they could be stored as 64 bit integers since SQLite has
the column type affinity feature).

If you like, I would be very happy to also supply diffs for you
to review for decimal floating point numbers as well.

If you like that idea, I was wondering what type of APIs
to use?  Some ideas:

(1) If we wanted to try to avoid any optional dependencies
on external floating or fixed point decimal arithmetic libraries,
and to avoid having to providing a tntdb decimal number class,
then we could provide APIs for decimal mantissa and base 10
exponents, something like:

class Value
{
  int64_t getDecimalInt64(int32_t &exponent) const;
  uint64_t getDecimalUnsigned64(int32_t &exponent) const;
};

class Statement
{
  Statement& setDecimalInt64(const std::string& col, int64_t data,
    int32_t exponent);
  Statement& setDecimalUnsigned64(const std::string& col, uint64_t data,
    int32_t exponent);
};

(2) We could add an autotools configure option to optionally use the
IBM decimal C library (ICU license), which is the so called decNumber
library at:

http://www2.hursley.ibm.com/decimal/
http://www2.hursley.ibm.com/decimal/dnfloat.html

and provide some sort of C++ numeric/number/decimal class
that calls decQuad APIs.

(IBM also have a C++ decNumber++ library, however it has
a restrictive license).

(3) Or we could just a C++ numeric/number/decimal class that does
not do much arithmetic, and the user could convert it to their
favourite decimal class to do something useful.

(4) Or however you like.

Thanks very much.

Thanks, Mark

PS. I'm working on trying to fix gcc 4.2.1/binutils 2.17
issues to compile cxxtools on Solaris.

On Fri, 13 Jul 2007 22:47:34 +1000
Mark Wright <[EMAIL PROTECTED]> wrote:

> On Thu, 12 Jul 2007 15:56:56 +0200
> Tommi Mäkitalo <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> > 
> > the concept of tntdb is currently to support the built-in numeric
> > C++ types int, unsigned, float and double. But indeed the int and
> > unsigned types are even on 64-bit systems only 32 bit. Currently to
> > only solution is to use float or double. I see, that there is a need
> > for 64-bit types.
> > 
> > The return type is then int64_t or uint64_t. Should we support then
> > explicit 32 bit types int32_t and uint32_t then also?
> 
> Hello Tommi,
> 
> I guess yes, whichever you prefer.
>  
> > The new methods for tntdb::Value are:
> >     int32_t getInt32() const
> >     uint32 getUnsigned32() const
> >     int64_t getInt64() const
> >     uint64_t getUnsigned64() const
> > 
> > The interface tntdb::IValue gets also these methods and every
> > implementation needs to be extended with them. Since the methods are
> > quite trivial to implement, I feel, that we should do that.
> > 
> > Currently in 0.9.2 there are drivers for sqlite3, mysql and
> > postgresql and in the svn-version is a driver for oracle.
> > 
> > Mark: it would be fine, if you send patches. I will integrate them.
> > 
> > Tommi
>  
> Great, thanks, I'll add these methods for sqlite3, mysql,
> postgresql and oracle, write a test, and send you
> the svn diff tntdb for your review.
> 
> Thanks, Mark
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general


-- 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to