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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:52:05+00:00 2026-06-05T22:52:05+00:00

I store some data in a database and I read those data with a

  • 0

I store some data in a database and I read those data with a cursor. All the data are 56.45 , 3.04, 0.03 type, so two numbers after the decimal point. Now I would like to sum them but it doesnt seem to be easy… I get those number with c.getDouble(3) then I add it to the sum variable like:

sum+= c.getDouble(4) * multi

multi is an integer between 1 and 100. Now my problem is that, after getting the sum variable I get a number like: 59.51999999999999999. I do not post a code, but there is no conversion except a string.valueOf for making the number appear on my widget. So anybody experienced this? As I count it should be 59.52, but instead I get that number with 99999… Why is that happening? (funny thing that with a Math.round() does not work, I get 59.0 even if I set (sum)*100 / 100..
Thanks in advance!

  • 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-06-05T22:52:06+00:00Added an answer on June 5, 2026 at 10:52 pm

    Other approach, you can define your sum variable as double and then you can set NumberFormat for your sum variable.

    Example:

    double sum = 21.2015;
    NumberFormat formatter = new DecimalFormat("#.##");
    formatter.format(sum);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a background thread to read from a Sqlite database some GPS data...and
I store some data as XML and the changes of the user as diff
I store some data in MySQL and want to filter out rows that match
I'd like to store some data in Python in a similar form to a
I'd like to store some data in a cookie and my initial though was
I want to store some data during my site viewing. Sometime i need to
In my app i store some data in the device storage. This data is
I am playing with neo4j to store some data with JAVA. I would like
I want to create a data store to allow me to store some data.
In my app I'm using an xml file to store some data, and images

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.