Skip to content

Instantly share code, notes, and snippets.

@blueberrystream
Created February 21, 2013 09:50
Show Gist options
  • Save blueberrystream/5003576 to your computer and use it in GitHub Desktop.
Save blueberrystream/5003576 to your computer and use it in GitHub Desktop.
桁落ちのなにが悪いんだ?
/**
* @author KID / @blueberrystream
*/
public class 桁落ち {
/**
* @param args
*/
public static void main(final String[] args) {
final Long l1 = System.currentTimeMillis();
final Long l2 = System.currentTimeMillis() + 5;
final Double d1 = l1.doubleValue() / 10000000000000L;
final Double d2 = l2.doubleValue() / 10000000000000L;
System.out.println(d1);
System.out.println(d2);
System.out.println(d2 - d1);
/*
出力例
0.1361440116519
0.1361440116524
5.000166947155549E-13
*/
}
}
@blueberrystream
Copy link
Author

桁落ちとは : JavaA2Z http://www.kab-studio.biz/Programing/JavaA2Z/Word/00000528.html これのサンプルプログラムのコメントでようやく理解。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment