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 181207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:43:16+00:00 2026-05-11T14:43:16+00:00

I have a bunch of floating point numbers (Java doubles), most of which are

  • 0

I have a bunch of floating point numbers (Java doubles), most of which are very close to 1, and I need to multiply them together as part of a larger calculation. I need to do this a lot.

The problem is that while Java doubles have no problem with a number like:

0.0000000000000000000000000000000001 (1.0E-34) 

they can’t represent something like:

1.0000000000000000000000000000000001 

Consequently of this I lose precision rapidly (the limit seems to be around 1.000000000000001 for Java’s doubles).

I’ve considered just storing the numbers with 1 subtracted, so for example 1.0001 would be stored as 0.0001 – but the problem is that to multiply them together again I have to add 1 and at this point I lose precision.

To address this I could use BigDecimals to perform the calculation (convert to BigDecimal, add 1.0, then multiply), and then convert back to doubles afterwards, but I have serious concerns about the performance implications of this.

Can anyone see a way to do this that avoids using BigDecimal?

Edit for clarity: This is for a large-scale collaborative filter, which employs a gradient descent optimization algorithm. Accuracy is an issue because often the collaborative filter is dealing with very small numbers (such as the probability of a person clicking on an ad for a product, which may be 1 in 1000, or 1 in 10000).

Speed is an issue because the collaborative filter must be trained on tens of millions of data points, if not more.

  • 1 1 Answer
  • 3 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. 2026-05-11T14:43:16+00:00Added an answer on May 11, 2026 at 2:43 pm

    Yep: because

    (1 + x) * (1 + y) = 1 + x + y + x*y 

    In your case, x and y are very small, so x*y is going to be far smaller – way too small to influence the results of your computation. So as far as you’re concerned,

    (1 + x) * (1 + y) = 1 + x + y 

    This means you can store the numbers with 1 subtracted, and instead of multiplying, just add them up. As long as the results are always much less than 1, they’ll be close enough to the mathematically precise results that you won’t care about the difference.

    EDIT: Just noticed: you say most of them are very close to 1. Obviously this technique won’t work for numbers that are not close to 1 – that is, if x and y are large. But if one is large and one is small, it might still work; you only care about the magnitude of the product x*y. (And if both numbers are not close to 1, you can just use regular Java double multiplication…)

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

Sidebar

Related Questions

I have a single dimensional array of floating point values (c# doubles FYI) and
I have bunch of methods in which i need to test whether remote server
I have a very large array of floating point image data: In[25]:= Dimensions[daylightImgd] Out[25]=
Its the standard float issue. You have a bunch of floating elements inside a
We have bunch of Domain Entities which should be rendered to an html format,
Does Java and/or Spring have the concept of properties? I have bunch of domain
I have a bunch of files that I need to be able to transport
I have a bunch of classes I want to rename. Some of them have
I have bunch of Symbol MC 70 devices. They run Windows Mobile 5. Most
I have bunch of files and very file has a header of 5 lines.

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.