Hi,

I was just looking at the PyXB API documentation. Is there any difference
in the PyXB implementation of xsd:float from xsd:decimal? Looking at:

http://pyxb.sourceforge.net/api/pyxb.binding.datatypes.decimal-class.html

it says that it inherits from the Python float type, which is an IEEE
binary floating point number. The XML Schema specification says that
xsd:float should be a 32 bit IEEE floating point number, but it seems stops
short on defining xsd:decimal as arbitrary precision - it just says at
least 18 decimal digits must be supported. But it is certainly true that
the way they define and describe xsd:float vs. xsd:decimal are quite
different.

(http://www.w3.org/TR/xmlschema-2/#decimal)

I note in the PyXB documentation it says:

"*To Do:* The Python base type for this is wrong. Consider
http://code.google.com/p/mpmath/";.

Is there any reason why the base python type shouldn't just be the built in
decimal type? From what I gather, this is arbitrary precision. As a point
of note, JAXB uses java.lang.BigDecimal (arbitrary precision floating point
number) for xsd:decimal.

Traditionally, we (as in, at my workplace) have used xsd:decimal for
monetary values in our XML documents, and obviously want to ensure that
under no circumstances these get rounded. I'm thinking of changing all the
types in my XML schema to xsd:string to avoid this type mapping issue, and
manually converting the string to an arbitrary precision decimal type
(probably the inbuilt python decimal type). But before I do that, is there
any chance that the type that PyXB uses can be or will be changed from
being based on an IEEE floating point number (with it's rounding and
precision issues) to an arbitrary precision decimal type of some sort?
Doing so seems to make sense - if the user really wants IEEE floating
point, xsd:float is the XML Schema type for that. And the documentation
seems to suggest that this was the thinking, at least at some point in the
past.

Or am I missing something here?

Regards,
Nathan.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
pyxb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to