From 092dd8db1293599a4b7f0ab33ea43e8082ec554f Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Tue, 17 Jan 2012 11:19:00 +0100 Subject: Replace float with Decimal Having float type as a base type for floating point parameters in ipalib introduces several issues, e.g. problem with representation or value comparison. Python language provides a Decimal type which help overcome these issues. This patch replaces a float type and Float parameter with a decimal.Decimal type in Decimal parameter. A precision attribute was added to Decimal parameter that can be used to limit a number of decimal places in parameter representation. This approach fixes a problem with API.txt validation where comparison of float values may fail on different architectures due to float representation error. In order to safely transfer the parameter value over RPC it is being converted to string which is then converted back to decimal.Decimal number on a server side. https://fedorahosted.org/freeipa/ticket/2260 --- doc/guide/guide.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/guide/guide.org b/doc/guide/guide.org index 68858166..bca7b34f 100644 --- a/doc/guide/guide.org +++ b/doc/guide/guide.org @@ -227,7 +227,7 @@ verbose = Flag('verbose', default=True) specified when constructing =Int= parameter: - /minvalue/ :: minimal value that this parameter accepts, defaults to =MININT= - /maxvalue/ :: maximum value this parameter can accept, defaults to =MAXINT= -- /Float/ :: floating point parameters that are stored in Python's float type. =Float= has +- /Decimal/ :: floating point parameters that are stored in Python's Decimal type. =Decimal= has the same two additional properties as =Int=. Unlike =Int=, there are no default values for the minimal and maximum boundaries. - /Bytes/ :: a parameter to represent binary data. @@ -294,9 +294,9 @@ class tank(Object): takes_params = ( StrEnum('species*', label=u'Species', doc=u'Fish species', values=(u'Angelfish', u'Betta', u'Cichlid', u'Firemouth')), - Float('height', label=u'Height', doc=u'height in mm', default=400.0), - Float('width', label=u'Width', doc=u'width in mm', default=400.0), - Float('depth', label=u'Depth', doc=u'Depth in mm', default=300.0) + Decimal('height', label=u'Height', doc=u'height in mm', default='400.0'), + Decimal('width', label=u'Width', doc=u'width in mm', default='400.0'), + Decimal('depth', label=u'Depth', doc=u'Depth in mm', default='300.0') ) api.register(tank) (ref:register) -- cgit