[Freeipa-devel] [PATCH] 192 Replace float with Decimal

Rob Crittenden rcritten at redhat.com
Thu Jan 19 22:08:15 UTC 2012


Martin Kosek wrote:
> On Tue, 2012-01-17 at 11:27 +0100, Martin Kosek wrote:
>> On Fri, 2012-01-13 at 21:02 +0100, Martin Kosek wrote:
>>> This patch fixes RHEL 6.2 build issue.
>>> ----
>>> Having float type as a base type for floating point parameter in
>>> ipalib introduces several issues, e.g. problem with representation
>>> or value comparison. Python language provides Decimal type which
>>> help overcome these issue.
>>>
>>> This patch replaces a float type with Decimal type in Float
>>> parameter. A precision attribute was added to Float 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
>>> number on server side.
>>>
>>> https://fedorahosted.org/freeipa/ticket/2260
>>>
>>
>> Sending an improved version of the patch with following major changes:
>>
>> 1) Float parameter was renamed to Decimal as it base type is different
>> and would confuse users otherwise.
>>
>> 2) Parameter maxvalue, minvalue and default can be also passed as a
>> string and not just as a decimal.Decimal value. Parameter definition is
>> then much simpler.
>>
>> 3) LDAP backend encoder was enhanced to support this new type (it
>> converts it to string just like a float value).
>>
>> Martin
>
> I forgot to add an encoding rule to JSON xmlrpc server. This can be
> useful in a future when Decimal type is actually used for a real LDAP
> attribute.
>
> Martin

ACK. This is fine API-wise because the data is transmitted as a string, 
so even if the client side defines the parameter as a Float it won't 
affect what the server receives. The only possible downside is that the 
precision requested on the client won't be honored on the server, but 
then again the server decides what level of precision we want to support.

rob




More information about the Freeipa-devel mailing list