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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:12:51+00:00 2026-05-24T20:12:51+00:00

I am building a basic calculator functionality in android. But I am facing little

  • 0

I am building a basic calculator functionality in android.
But I am facing little problem with rounding up the numbers when the result is get displayed in the TextView.

I am doing multiplication of 123456789 * 123456789 and getting result which I am not able to accommodate in my TextView.
Also the Actual result of above operation is 1.5241E16 when performed in Android’s in built Calculator.
Can anyone tell me that how can I achieve this result in my calculator app?
Below is little snippet about what I am trying to do:

public static double round(double unrounded, int precision, int roundingMode)
    {
        BigDecimal bd = new BigDecimal(unrounded);
        BigDecimal rounded = bd.setScale(precision, roundingMode);
        return rounded.doubleValue();
    }

    num = num * Double.parseDouble(txtCalc.getText().toString());
    num = round(num, 3, BigDecimal.ROUND_HALF_UP); //where 3 is the precision of number

Plz Help me to achieve the result 1.5241E16 for 1…9 * 1….9

  • 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-24T20:12:52+00:00Added an answer on May 24, 2026 at 8:12 pm

    The scientific notation does lose accuracy. 1.5241E16 simply means the answer is roughly 1.5241*10,000,000,000,000,000 meaning if you can decide how many decimal places you want to display, you can just divide you number by 10^X and concatenate the result.

    So if my resulting number was 1234567890 and I wanted to display this to 3 decimal places. I would do 1234567890 / 10^9 (because there are 9 digits after the first digit) and then I would simply cancatenate everything after char 5 (1 place for the whole number, 1 place for the dot and then 3 decimal places). If you want to round the last decimal place, simply check if the number at position 6 is greater than or eqaul to 5 and just increment the last number by 1.

    Here this gives the result you desire.

    double num1 = 123456789L;
    double num2 = 123456789L;
    String result = num1*num2+"";
    if(result.contains("E")){ //if result is in scientific notation
        //take the first 6 characters only and part containing the E, drop everything else.
        result = result.substring(0, 6) + result.substring(result.indexOf("E"));
    }
    System.out.println("Result is = " + result);
    

    The output from my Groovy shell:

    Result is = 1.5241E16

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

Sidebar

Related Questions

I'm building a basic search functionality, using LIKE (I'd be using fulltext but can't
I'm building a basic little AJAX shoutbox/chat for my website, but I'm not sure
I'm looking at building basic CMS functionality into our web product and am researching
I'm currently building a GWT login screen and I managed to get a basic
I'm building a basic calculator app for iPhone. I've got all the basics in
I am building a basic profiler for an open source project. One requirement is
I am building a basic Image editor. In my app, if the user wants
I'm building a basic forum where every post contains some text, first and last
I'm building a basic CRUD library, that I anticipate use in both local (add
I am building some basic HTML code for a CMS. One of the page-related

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.