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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:20:05+00:00 2026-05-21T03:20:05+00:00

I am currently writing a calculator application. I know that a double is not

  • 0

I am currently writing a calculator application. I know that a double is not the best choice for good math. Most of the functions in the application have great precision but the ones that don’t get super ugly results. My solution is to show users only 12 decimals of precision. I chose 12 because my lowest precision comes from my numerical derive function.

The issue I am having is that if I multiply it by a scaler then round then divide by the scaler the precision will most likely be thrown out of whack. If I use DecimalFormat there is no way to show only 12 and have the E for scientific notation show up correctly, but not be there if it doesn’t need to be.

for example I want

1.23456789111213 to be 1.234567891112

but never

1.234567891112E0

but I also want

1.23456789111213E23 to be 1.234567891112E23

So basically I want to format the string of a number to 12 decimals places, preserving scientific notation, but not being scientific when it shouldn’t

  • 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-21T03:20:06+00:00Added an answer on May 21, 2026 at 3:20 am

    Use String.format("%.12G", doubleVariable);

    That is how you use format() to display values in scientific notation, but without the scientific notation if not needed. The one caveat is that you end up with a ‘+’ after the ‘E’, so yours would end up like 1.234567891112E+23

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

Sidebar

Related Questions

I'm currently writing a script that takes a database as input and generates all
I am writing a Linux (Ubuntu and Debian Lenny) application in C++. Now I
I'm writing a stopwatch application for BlackBerry (which is similar to the BlackBerry built-in
I have a database that tracks employee’s data for the current year and previous
I'm currently developing a percussion tutorial program. The program requires that I can determine
I'm writing a little Java client side app which uploads things using http streams
I'm having problems correctly calculating tax and discounts per item, mainly because I'm not
I'm writing a currency converter but I'm having a bit of trouble caculating the
I'm writing a gem to detect tracking numbers (called tracking_number , natch). It searches
I'm writing an image manipulation tool and, for image quality reasons, want to edit

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.