title: JAXB, BigDecimal or double?
body: <p>I working on different web-services, and I always use WSDL First.</p>
  
  <p>JAXB generates for a Type like:</p>
  
  <pre><code>&lt;xsd:simpleType name="CurrencyFormatTyp"&gt;
      &lt;xsd:restriction base="xsd:decimal"&gt;
          &lt;xsd:totalDigits value="13"/&gt;
          &lt;xsd:fractionDigits value="2"/&gt;
          &lt;xsd:minInclusive value="0.01"/&gt;
      &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
  </code></pre>
  
  <p>a Java binding type <code>BigDecimal</code> (as it's mentioned in JAXB specification).</p>
  
  <p>When I then do some simple arithmetic operation with values of the type <code>double</code> (which are stored in a database and mapped via hibernate to the type double) I run into trouble.</p>
  
  <pre><code>&lt;ns5:charge&gt;0.200000000000000011102230246251565404236316680908203125&lt;/ns5:charge&gt;        
  &lt;ns5:addcharge&gt;0.0360000000000000042188474935755948536098003387451171875&lt;/ns5:addcharge&gt;
  &lt;ns5:tax&gt;0.047199999999999998900879205621095024980604648590087890625&lt;/ns5:tax&gt;
  &lt;ns5:totalextax&gt;0.2360000000000000153210777398271602578461170196533203125&lt;/ns5:totalextax&gt;
  </code></pre>
  
  <p>What would be the right way?</p>
  
  <ol>
  <li>Convert all my values into double (JAXB binding from <code>BigDecimal</code> to <code>double</code>)</li>
  <li>Hibernate mapping <code>double</code> to <code>Bigdecimal</code></li>
  </ol>
  
  <p>and do all my arithmetic operations in one object type.</p>