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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:03:59+00:00 2026-06-18T09:03:59+00:00

String s = 128166947252913248; DecimalFormat df = new DecimalFormat(##########################.########); Double oldTime1 = new Double(s);

  • 0
String s = "128166947252913248";
DecimalFormat df = new DecimalFormat("##########################.########");
Double oldTime1 = new Double(s); 
Double oldTime2 = new Double("128166947252913249"); 
Double oldTime3 = new Double("128166947252913247");
Double newTime = new Double("116444736000000000");
System.out.println(newTime.longValue());
System.out.println(df.format(oldTime1));
System.out.println(oldTime1-newTime);
System.out.println(df.format(oldTime1-newTime));
System.out.println(df.format(oldTime3-newTime));

Output is :

116444736000000000
128166947252913248
1.1722211252913248E16
11722211252913248
11722211252913248

This is the code I am working on. I am unable to stop double variable getting truncated at the last variable. Please help me to get a value without being truncated.

  • 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-18T09:04:00+00:00Added an answer on June 18, 2026 at 9:04 am

    Try Using BigDecimal

    String s = "128166947252913248";
    DecimalFormat df = new DecimalFormat(
            "##########################.########");
    BigDecimal oldTime1 = new BigDecimal(s);
    BigDecimal oldTime2 = new BigDecimal("128166947252913249");
    BigDecimal oldTime3 = new BigDecimal("128166947252913247");
    BigDecimal newTime = new BigDecimal("116444736000000000");
    System.out.println(newTime.longValue());
    System.out.println(df.format(oldTime1));
    System.out.println(oldTime1.subtract(newTime));
    System.out.println(df.format(oldTime1.subtract(newTime)));
    System.out.println(df.format(oldTime3.subtract(newTime)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

String[] names=new String[4]; int[] scores=new int[4]; Scanner keyboard = new Scanner(System.in); System.out.println(Enter 4 strings
String word=i love apples i love orange; String w=scan.next(); int index = word.indexOf(w); System.out.println
String x = Welcome to Java World; System.out.println(x.replaceAll(.*,JAVA)); Actual Output = JAVAJAVA . Excepted
String a = Hello\u200e; String b = Hello\u200f; System.out.println(a = ' + a +
string value1 , value1 ; int length1 , length2 ; System.Collections.BitArray bitValue1 = new
string[] strArray = new string[10] { 21.65, 30.90, 20.42, 10.00, 14.87, 72.19, 36.00, 45.11,
string[] lines3 = new string[100]; List<string> lines2 = new List<string>(); lines3 = Regex.Split(s1, @\s*,\s*);
string x = <select><option value='2'>dfgdfh</option><option value='3'>cvncvn</option><option value='4'>cvn</option><option value='5'>dhdfh</option><option value='6'>dfhdfh</option><option selected=selected value='7'>dfhdfh</option><option value='8'>dfgfdh</option><option value='12'>New type</option></select>
string[][] Tablero = new string[3][3]; I need to have a 3x3 array arrangement to
string from = abc@gmail.com; string to = xyz@gmail.com,xyz@yahoo.co.in; string password=abcxyz; MailMessage mail = new

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.