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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:02:53+00:00 2026-06-05T12:02:53+00:00

Alright, so I got a test program: public class ParseTest { public static void

  • 0

Alright, so I got a test program:

public class ParseTest {
    public static void main(String[] args){
        String s = "-0.000051";
        System.out.println(s + " != " + Float.parseFloat(s));
    }
}

and it’s not out putting the same number on both sides. This is the output:

-0.000051 != -5.1E-5

So, why isn’t it outputting the same number on both sides?

  • 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-05T12:02:54+00:00Added an answer on June 5, 2026 at 12:02 pm

    It is the same number just different scientific representation,

    For example:

    100 = 1E2 
    

    and

    0.1 = 1E-1
    

    How to get same representation ?

    If you want the same representation then use BigDecimal

    System.out.println(s + " != " + new BigDecimal(s));
    

    Who is converting it to this format ?

    when you convert primitive to String by for example

    float f = 100.123;
    String result = "" + f; 
    

    It calls the Float.valueOf(f) which inturns calls the Float.toString() which inturn calls the new FloatingDecimal(f).toJavaFormatString(); this is where this stuff is encapsulated

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

Sidebar

Related Questions

Alright, so I created a JavaScript file named HelloWorld.js with the following contents: java.lang.System.out.println(Hello
i've got regex which was alright, but as it camed out doesn't work well
Alright guys, so I've got a GameObject class and I inherited it to my
Alright, this is basic c++ here. I've got a class that is a Linear
Alright, I finally got this code to work after hours of toiling: Dim path
Alright, I hope this isn't too broad a question but my curiosity got the
Alright.. I'm struggling with this one.. I've got an image with a transparent hole
Alright so I've got this script sort of working. The ajax call works and
Alright this probably sounds easier than it is :) I've got two files: file1.php
Alright, so I got my form to email most of the variables in php.

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.