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

  • SEARCH
  • Home
  • 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 6968775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:29:45+00:00 2026-05-27T16:29:45+00:00

It is known that java floating point primitive values are not to be used

  • 0

It is known that java floating point primitive values are not to be used when arbitrary precision is required. Goetz explained the problem in his excellent article.

Imagine we need to achieve arbitrary precision in a certain project and we don’t have a BigDecimal class (because it is not available in the API, e.g.: JavaME) nor have time to develop a custom implementation. Provided we know in advance that only a relatively small precision is required (2 to 4 decimals), would it be possible to implement a 100% reliable emergency workaround using float and double types and a rounding function? And if so, which function in the API could be used?
In case this function were not available, but still you think it could address the problem, how complex would it be to implement it?

  • 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-27T16:29:45+00:00Added an answer on May 27, 2026 at 4:29 pm

    No, it wouldn’t be possible because some values can’t be represented using floating point arithmetic. 0.1 is the simplest example.

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

Sidebar

Related Questions

Possible Duplicate: Retain precision with Doubles in java Floating point inaccuracy examples I know
A well known problem with Java Applets in webpages is that browsers ignore the
Creating a layout in Java as the number of TableLayouts required is not known
General Problem I have some objects that have some variables that are not known
Its known that Java ArrayList is implemented using arrays and initializes with capacity of
I have to develop a Java ME (formerly known as J2ME) application that will
Does anybody know a Java implementation of the DRMAA-API that is known to work
In Java it's known that using the assert keyword is usually a bad idea,
I'm not experienced with java applications but I found out that finding static pointers
It is a known fact, that in Java it is good practice to return

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.