[omniORB] bug in CORBA::Fixed constructor

OKeeffe, Michael K MOKEEFFE at amfam.com
Wed Jan 3 12:34:31 GMT 2007


>[snip]

>As for arithmetic, both the Java class "java.math.BigDecimal" and the
>Python
>class "decimal.Decimal" do floating-point decimal arithmetic which
>maintains
>trailing zeros, eg:
>
>>>> from decimal import Decimal
>>>> Decimal("1.10")*Decimal("1.10")
>Decimal("1.2100")
>
>So apparently maintaining trailing zeros through arithmetic like this
>makes
>sense to some people.  Personally I can't see the use of this behaviour
>in
>arithmetic so I'm not going to argue with you that it makes sense :-)

Here are a few reasons:
http://www2.hursley.ibm.com/decimal/decifaq1.html#tzeros

>> I think that bit of the spec is inconsistent with the other 
>parts that
>> describe how fixed literals get involved in arithmetic, and with the
>> details of the language mappings. Fixed point is generally very badly
>> specified in all the CORBA specs.
>
>Yes, I've noticed that fixed point in general does seem poorly thought
>out
>in the CORBA specs.  What in particular are you referring to as an
>inconsistency here?  I can't see why significant trailing and leading
>zeros
>in string literals couldn't be implemented consistently with the spec.
>
Your BigDecimal example gives a hint that that it's poorly thought out
elsewhere besides the CORBA spec.  The java class was not part of the
standard Java types (Integer, Float, Long), it was probably tacked on
later (and revised for Java 1.5), in a separate package (math), that
only includes BigDecimal and BigInteger!  Further, from the Hursley link
above you'll find a link to the *revised* IEEE 754 spec, which covers
binary floating-point arithmetic. 

The paper below which gives a few examples of why a floating scale is
advantageous over fixed, and also some of the historical aspects such as
some of the original machines used decimal arithmetic, but von Neummann
was behind the move to binary arithmetic for simplicity.

http://www2.hursley.ibm.com/decimal/IEEE-cowlishaw-arith16.pdf



More information about the omniORB-list mailing list