[Cubicweb] Float / Decimal CW Data types
carlos.balderas at gmail.com
Mon Dec 13 16:39:35 CET 2010
Adrien, thank you for this very detail explanation.
Thanks a lot for your support.
On Mon, Dec 13, 2010 at 1:48 AM, Adrien Di Mascio <
adrien.dimascio at logilab.fr> wrote:
> Hi Carlos,
> On 13/12/2010 00:51, Carlos Balderas wrote:
>> Would you please give me an advise about when to use Float or Decimal
>> in Cubicweb.
> The answer is the same as it would be in Python. Use Decimal if you need to
> perform exact calculations (e.g banking, payroll applications). In other
> cases, standard floating point arithmetic should suit your needs, and Float
> is probably the best choice, it's faster (both in SQL and in Python) and
> probably more convenient.
> From a SQL point of view, Decimal attributes are converted to ``DECIMAL``
> sql type (or NUMERIC, I believe they're equivalent) whereas Float attributes
> will use ``FLOAT``.
> In Python, Decimal attributes will be deserialized with the
> ``decimal.Decimal`` type, Float attributes will use the standard float type.
> I would suggest you to read, if you havent' done yet, the documentation
> of the ``decimal`` stdlib module :
> When displaying decimal attributes in form creation/edition, the input
>> box's size looks like the size of a "text" value, making a little bit of
>> confusion at first sight at the time to capture the values, IMHO.
> I don't have any strong opinion on this. However, our implementation of
> Decimal is a bit incomplete : we should be able to specify a precision for
> decimal values. e.g. :
> debt = Decimal(precision=15, scale=12)
> In that case, the input field in form should adapt to the precision
> specified in the schema.
> Adrien Di Mascio - LOGILAB, Paris (France).
> Tél: 01.45.32.03.12
> Formations - http://www.logilab.fr/formations
> Développements - http://www.logilab.fr/services
> Gestion de connaissances - http://www.cubicweb.org/
> Cubicweb mailing list
> Cubicweb at lists.cubicweb.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cubicweb