Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 775817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:21:08+00:00 2026-05-14T19:21:08+00:00

I working on different web-services, and I always use WSDL First. JAXB generates for

  • 0

I working on different web-services, and I always use WSDL First.

JAXB generates for a Type like:

<xsd:simpleType name="CurrencyFormatTyp">
    <xsd:restriction base="xsd:decimal">
        <xsd:totalDigits value="13"/>
        <xsd:fractionDigits value="2"/>
        <xsd:minInclusive value="0.01"/>
    </xsd:restriction>
</xsd:simpleType>

a Java binding type BigDecimal (as it’s mentioned in JAXB specification).

When I then do some simple arithmetic operation with values of the type double (which are stored in a database and mapped via hibernate to the type double) I run into trouble.

<ns5:charge>0.200000000000000011102230246251565404236316680908203125</ns5:charge>        
<ns5:addcharge>0.0360000000000000042188474935755948536098003387451171875</ns5:addcharge>
<ns5:tax>0.047199999999999998900879205621095024980604648590087890625</ns5:tax>
<ns5:totalextax>0.2360000000000000153210777398271602578461170196533203125</ns5:totalextax>

What would be the right way?

  1. Convert all my values into double (JAXB binding from BigDecimal to double)
  2. Hibernate mapping double to Bigdecimal

and do all my arithmetic operations in one object type.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:21:09+00:00Added an answer on May 14, 2026 at 7:21 pm

    You don’t ever want to use floating point formats (such as double and float in Java) for currency operations, because they have limited precision and have been designed to hold values that are somehow derived from measuring (in which case they aren’t absolutely precise to begin with, in which case the limited precision is less of a problem).

    What Every Computer Scientist Should Know About Floating-Point Arithmetic is the article on the topic. It’s a bit heavy on math, but it really helps to understand that (Alternatively, the article linked to by Michael Borgwardt is much easier to understand and still demonstrates/explains the problem).

    To avoid this kind of problems, make sure that you use BigDecimal exclusively in your code and that all external storage/transfer points use fixed-point/arbitrary-precision values as well (i.e. your database shouldn’t store floating point numbers either).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using VS2010. The projects that I'm working on use different source control providers,
I'm working on a project where I have different sets of div like heading,
We are working on a SOA Project consisting of multiple web services. Each web
Scenario: I'm working on a web services project. It supports SOAP and REST. The
I'm currently working on an application wich will do four things via web services
I am working on a ASP.NET MVC 2.0 Multi-Presentation web application which would use
I am working on a web project that contains three web services and a
I'm very new to working with web services, and so I'm finding this pretty
The Django-based web application I'm working on is translated to a few different languages.
I'm working with some web services that have already been created and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.