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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:02:16+00:00 2026-05-25T16:02:16+00:00

What would be printed to console and why? 1. BigDecimal BigDecimalNum = new BigDecimal(0.0774);

  • 0

What would be printed to console and why?

1.

BigDecimal BigDecimalNum = new BigDecimal("0.0774");
System.out.println(BigDecimalNum.doubleValue() * 100.00);

2.

BigDecimal BigDecimalNum2 = new BigDecimal("0.0774");   
System.out.println(BigDecimalNum2.multiply(new BigDecimal("100.00")));
  • 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-25T16:02:17+00:00Added an answer on May 25, 2026 at 4:02 pm

    The results on my machine are:

    7.739999999999999
    7.740000
    

    This doesn’t surprise me at all. In the second case we’re dealing entirely with BigDecimal, and always multiplying – there’s no reason for anything to go wrong.

    In the first case you’re converting the BigDecimal to a double, so your code is effectively

    double d = 0.0774;
    System.out.println(d * 100.0);
    

    The value 0.0774 can’t be exactly represented as a double, hence the discrepancy.

    This has nothing to do with BigDecimal, and everything to do with double. You should almost never be converting between BigDecimal and double though – the kind of values which are appropriate for use in BigDecimal are almost always inappropriate to represent as double values.

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

Sidebar

Related Questions

I would like to color format the text printed to the console using the
From the code below, I though thhat y would be printed out before x,
I would like to format my log message before being printed out on the
I occasionally find that it would be useful to get the printed representation of
Would it be possible to add a new operator to the String class that
Would anyone be able to tell me how to pull the server name out
I was recently making a very simple application that just printed matrix-effect out to
I would like to be able to change the printer properties without bringing up
Would following the table below be the best way of determining the access type
Would it be ok to put an average price calculation, as below, in the

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.