convert very small double to a String

cd1 :

I have a very small number and I want to convert it to a String with the full number, not abbreviated in any way. I don't know how small this number can be.

for example, when I run:

double d = 1E-10;
System.out.println(d);

it shows 1.0E-10 instead of 0.000000001.

I've already tried NumberFormat.getNumberInstance() but it formats to 0. and I don't know what expression to use on a DecimalFormat to work with any number.

ryanprayogo :

Assuming that you want 500 zeroes in front of your number when you do:

double d = 1E-500;

then you can use:

double d = 1E-10;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(Integer.MAX_VALUE);
System.out.println(nf.format(d));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

python not able to convert very small decimal to log

How to convert a double to a small string representation without data loss in any lua without external libs?

Very small simple precision and double precision float numbers representation

Convert a String to Double - Java

jsoncpp: convert string to double

convert String to double with '%'

Convert Double to String Android

Convert string to double (NOT decimal)

Convert a string to a double for a if clause

convert string to double not working?

How to convert very small numbers from strings to floats properly in Python?

What's the fastest way to write a very small string to a file in Java?

Segmentation fault in a very small c program for accepting and printing a string

How to convert from a string to a double to a double*

How convert string double into numeric double in R?

Swift: convert [Dictionary<String, [String : Double]>.Element] to [String : [String : Double]]

Convert a string with hex value of a very big number

How to convert a very large decimal number to a string?

How to convert a very large decimal string to hexadecimal?

Convert very large number stored as string into number

Python convert string to datetime but formatting is not very predictable

Convert hexadecimal string to double in Java

Read CSV and convert string to double

iOS Swift - Convert String with $ to Double

Best practice to convert a Double to a String

Cannot convert string to type 'Double'

XJC restriction convert Double to String

How to convert string to double in angular

Fail to convert string to double Swift