couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tibor Gemes <tib...@gmail.com>
Subject Re: Fixed precision of floating point number not respected in views
Date Tue, 19 Feb 2013 21:58:57 GMT
It's against best practices to use floats for representing money. If you
count pennies, then interpret the amount in pennies with int.
If this inconsistency is unacceptable, then you must use int. You should
use float only if this does not matter.
T
2013.02.19. 22:48, "Robert Newson" <rnewson@apache.org> ezt írta:

> I agree entirely with your last statement (I filed
> https://issues.apache.org/jira/browse/COUCHDB-1410 for exactly that
> reason).
>
> However, I've been convinced that it cannot be done with
> Javascript/JSON's meaning of number, hence the suggestion to protect
> your values inside strings (which will not be altered or interpreted)
> and use math functions that operate on them (the various bignum.js
> libraries, for example). Another way to think of this is by
> comparison; if you would be happy, in Java, to exclusively use
> doubles, you'd be fine here. An important place where that is not
> acceptable is money (and, related, currency). You can't invent
> pennies.
>
> I'm +1 on including such a feature in a future release of CouchDB, but
> I don't think I got consensus on the idea so far (since it can be done
> today without such an extension).
>
> B.
>
>
> On 19 February 2013 21:39, Luca Morandini <lmorandini@ieee.org> wrote:
> > On 02/20/2013 08:23 AM, Robert Newson wrote:
> >>
> >>
> >> The numbers are not being changed, you are simply being exposed to the
> >> truth. :)
> >
> >
> > Nicely and concisely put, though it must be noted that Node.js -for
> > instance- keeps hiding the truth, hence there is a bit of inconsistency.
> >
> > But what if I rely on that low-fidelity representation ?
> > This is a DBMS, people expects to get exactly what they put into it.
> >
> >
> > Regards,
> >
> > Luca Morandini
> > Data Architect - AURIN project
> > Department of Computing and Information Systems
> > University of Melbourne
> > Tel. +61 03 903 58 380
> > Skype: lmorandini
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message