0

In java if we have a number, which is double, like this 0.619879223757707784592145.

It will show it as 6.19879223757707e-4, when you print that number.

I am asking that whether i can print this number as 0.000619.

In C#, we can use the code below

Console.WriteLine("Number{3:0.000000}",num);//output: 0.000619

In Java, we can write this as below

System.out.printf("%.6f\n",num);//output:0.000619

But my question is how to truncate and store that value in a database or a file in java?

The above solutions only answers how to print that value(0.000619) in a command prompt.But I want to truncate as well as store the value in a file or a database, at the same time.

  • For Java, see this answer: http://stackoverflow.com/questions/2808535/round-a-double-to-2-significant-figures-after-decimal-point . – tmuguet Jan 20 '13 at 15:27
  • Sorry this doesn't answer my question. – Rama Lakshmi Jan 20 '13 at 15:59
  • When i try to truncate this number,8.100661301985755E-5,as mentioned by you it displays as 0.000081.But when I try to store it in the database,it gets stored as 8.1E-5, but i want to get it stored as 0.000081.What should i do for that? – Rama Lakshmi Jan 20 '13 at 16:01

0 Answers0