Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a small number using java

Tags:

java

How to write a very small number, which is approaching the limit 0? Like this:

double eps = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001;

This is a constant, but in the code it looks terrible. Is there a shorter form?

like image 440
cagounai Avatar asked Nov 27 '25 21:11

cagounai


1 Answers

Java supports scientific notation for expressing double literals. You can write a small number, say, 10-12 like this:

double eps = 1E-12;
like image 160
Sergey Kalinichenko Avatar answered Nov 29 '25 11:11

Sergey Kalinichenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!