{"id":1547,"date":"2019-03-28T12:00:59","date_gmt":"2019-03-28T03:00:59","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=1547"},"modified":"2025-10-06T17:29:04","modified_gmt":"2025-10-06T08:29:04","slug":"java-double","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/java-double","title":{"rendered":"Java\u306edouble\u3068\u306f\uff1f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e\u4e00\u3064\u300cdouble\u300d\u3092\u89e3\u8aac"},"content":{"rendered":"<p><strong>Java\u306edouble\u306f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e\u4e00\u3064\u3067\u3001\u5c0f\u6570\u70b9\u3092\u6301\u3064\u6570\u5b57\u309264\u30d3\u30c3\u30c8\u306e\u7bc4\u56f2\u3067\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<\/strong><br \/>\n<span>double<\/span>\u306f\u6d6e\u52d5\u5c0f\u6570\u70b9\u3068\u6307\u6570\u8868\u8a18\u3068\u3044\u3046\u8003\u3048\u65b9\u306e\u304a\u304b\u3052\u3067\u3001\u304a\u3088\u305d<span>10<\/span>\u306e<span>308<\/span>\u4e57\u3068\u3044\u3046\u3068\u3066\u3082\u5927\u304d\u306a\u6570\u5b57\u304b\u3089\u3001<span>10<\/span>\u306e\u30de\u30a4\u30ca\u30b9<span>324<\/span>\u4e57\u3068\u3044\u3046\u3068\u3066\u3082\u5c0f\u3055\u3044\u6570\u5b57\u307e\u3067\u3001\u5927\u5909\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u6271\u3048\u307e\u3059\u3002<\/p>\n<p>double\u3092\u4f7f\u3048\u3070\u7c21\u5358\u30fb\u9ad8\u901f\u306b\u8a08\u7b97\u3067\u304d\u307e\u3059\u304c\u3001\u304d\u3061\u3093\u3068\u7406\u89e3\u3092\u3057\u306a\u3044\u307e\u307e<span>double<\/span>\u3092\u4f7f\u3046\u3068\u3001\u300c\u3069\u3046\u3057\u3066\u3053\u306e\u8a08\u7b97\u7d50\u679c\u306b\u306a\u308b\u306e<span>?<\/span>\u300d\u3068\u306a\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u7279\u306b\u3001<span>64<\/span>\u30d3\u30c3\u30c8\u3082\u3042\u308b\u3068\u306f\u3044\u3048\u30b5\u30a4\u30ba\u306b\u9650\u308a\u304c\u3042\u308b\u3053\u3068\u3084\u3001<span>2<\/span>\u9032\u6570\u306b\u3088\u308b\u3044\u308d\u3044\u308d\u306a\u5236\u9650\u3084\u8a08\u7b97\u4e0a\u8d77\u304d\u308b\u8aa4\u5dee\u304b\u3089\u306f\u9003\u308c\u3089\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u3060\u304b\u3089\u3053\u305d\u3001<span>double<\/span>\u306e\u7279\u5fb4\u3084\u4f7f\u3044\u65b9\u3092\u3057\u3063\u304b\u308a\u77e5\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u6570\u5024\u8a08\u7b97\u304c\u3057\u3063\u304b\u308a\u3068\u884c\u3048\u308b\u30b9\u30ad\u30eb\u304c\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u3069\u306e\u3088\u3046\u306a\u8a08\u7b97\u8aa4\u5dee\u304c\u3069\u306e\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3067\u767a\u751f\u3059\u308b\u304b\u3042\u3089\u304b\u3058\u3081\u5206\u304b\u3063\u3066\u3044\u308c\u3070\u5bfe\u7b56\u306f\u3057\u3063\u304b\u308a\u3068\u3067\u304d\u307e\u3059\u3057\u3001\u7d50\u679c\u3068\u3057\u3066\u5b9f\u7528\u4e0a\u6c42\u3081\u3089\u308c\u308b\u7cbe\u5ea6\u3067\u306e\u8a08\u7b97\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f<span>double<\/span>\u306b\u3064\u3044\u3066\u3001<strong><span class=\"f-marker-p\">\u305d\u3082\u305d\u3082double\u3068\u306f\u3069\u3046\u3044\u3046\u3082\u306e\u304b<\/span><\/strong>\u3001<strong><span class=\"f-marker-p\">double\u306f\u3069\u3046\u3084\u3063\u3066\u4f7f\u3046\u306e\u304b<\/span><\/strong>\u3001\u6c17\u3092\u4ed8\u3051\u305f\u3044\u6240\u306a\u3069\u3092\u521d\u5fc3\u8005\u5411\u3051\u306b\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002<\/p>\n<p>\u203b\u3053\u306e\u8a18\u4e8b\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u3001<span>Java 11<\/span>\u306e\u74b0\u5883\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Javadouble64\">\uff11\uff0e\u3010Java\u3011double\u3068\u306f64\u30d3\u30c3\u30c8\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570<\/a><ul><li><a href=\"#-double\">\uff11-\uff11\uff0edouble\u306f\u6307\u6570\u8868\u8a18\u3067\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u8868\u73fe\u3059\u308b<\/a><\/li><li><a href=\"#-double-2\">\uff11-\uff12\uff0edouble\u306f\u8aa4\u5dee\u3068\u4e00\u84ee\u6258\u751f<\/a><\/li><li><a href=\"#-Javadouble\">\uff11-\uff13\uff0eJava\u306edouble\u306f\u56fd\u969b\u6a19\u6e96\u898f\u683c\u6e96\u62e0<\/a><\/li><\/ul><\/li><li><a href=\"#double\">\uff12\uff0edouble\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a><ul><li><a href=\"#-double-3\">\uff12-\uff11\uff0edouble\u306e\u5ba3\u8a00\u306e\u4ed5\u65b9\u3001\u521d\u671f\u5024\u3001\u30ea\u30c6\u30e9\u30eb<\/a><\/li><li><a href=\"#-double-4\">\uff12-\uff12\uff0edouble\u3092\u4f7f\u3063\u305f\u56db\u5247\u6f14\u7b97<\/a><\/li><li><a href=\"#-double-5\">\uff12-\uff13\uff0edouble\u3068\u30d3\u30c3\u30c8\u6f14\u7b97<\/a><\/li><li><a href=\"#-double-6\">\uff12-\uff14\uff0edouble\u540c\u58eb\u306e\u6bd4\u8f03\u306b\u306f\u6c17\u3092\u4ed8\u3051\u3088\u3046<\/a><\/li><\/ul><\/li><li><a href=\"#double-2\">\uff13\uff0edouble\u3068\u4ed6\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u306e\u5909\u63db<\/a><ul><li><a href=\"#-doubledouble\">\uff13-\uff11\uff0edouble\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u2192double\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/a><\/li><li><a href=\"#-doubledouble-2\">\uff13-\uff12\uff0edouble\u2192double\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/a><\/li><\/ul><\/li><li><a href=\"#doubleString\">\uff14\uff0edouble\u3068String\u3068\u306e\u5909\u63db<\/a><ul><li><a href=\"#-Stringdouble\">\uff14-\uff11\uff0eString\u2192double\u306e\u5909\u63db<\/a><\/li><li><a href=\"#-doubleString\">\uff14-\uff12\uff0edouble\u2192String\u306e\u5909\u63db<\/a><\/li><\/ul><\/li><li><a href=\"#doubleDouble\">\uff15\uff0edouble\u3068Double<\/a><ul><li><a href=\"#i\">\uff15-\uff11\uff0e\u4e8c\u7a2e\u985e\u306e\u8868\u73fe\u65b9\u6cd5\u306f\u6027\u80fd\u78ba\u4fdd\u306e\u305f\u3081<\/a><\/li><li><a href=\"#-Doublenull\">\uff15-\uff12\uff0e\u30af\u30e9\u30b9\u306eDouble\u306a\u3089null\u3092\u8868\u73fe\u3067\u304d\u308b<\/a><\/li><li><a href=\"#-doubleDouble\">\uff15-\uff13\uff0e\u30aa\u30fc\u30c8\u30dc\u30af\u30b7\u30f3\u30b0\u3067double\u3068Double\u3092\u81ea\u52d5\u5909\u63db\u3059\u308b<\/a><\/li><\/ul><\/li><li><a href=\"#double-3\">\uff16\uff0e\u3010\u767a\u5c55\u3011double\u3068\u8aa4\u5dee<\/a><ul><li><a href=\"#i-2\">\uff16-\uff11\uff0e\u4e38\u3081\u8aa4\u5dee\/\u6253\u5207\u308a\u8aa4\u5dee<\/a><\/li><li><a href=\"#i-3\">\uff16-\uff12\uff0e\u6841\u843d\u3061<\/a><\/li><li><a href=\"#i-4\">\uff16-\uff13\uff0e\u60c5\u5831\u843d\u3061<\/a><\/li><li><a href=\"#-BigDecimal\">\uff16-\uff14\uff0eBigDecimal\u306b\u3088\u308b\u6b63\u78ba\u306a\u8a08\u7b97\u306e\u4f8b<\/a><\/li><\/ul><\/li><li><a href=\"#i-5\">\uff17\uff0e\u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Javadouble64\">\uff11\uff0e\u3010Java\u3011double\u3068\u306f<span>64<\/span>\u30d3\u30c3\u30c8\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570<\/span><\/h2>\n<p><strong>double(\u30c0\u30d6\u30eb)\u306f\u3001\u5c0f\u6570\u70b9\u4ee5\u4e0b\u3092\u542b\u3080\u5e45\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u6271\u3048\u308b\u30c7\u30fc\u30bf\u578b\u3067\u3001\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b(primitive\u3001\u57fa\u672c\u30c7\u30fc\u30bf\u578b)\u306e\u4e00\u3064\u3067\u3059\u3002<\/strong>\u4e00\u3064\u306e<span>double<\/span>\u306e\u30b5\u30a4\u30ba\u306f<span>64<\/span>\u30d3\u30c3\u30c8<span>(8<\/span>\u30d0\u30a4\u30c8<span>)<\/span>\u3067\u3059\u3002<span>double<\/span>\u306f\u300c\u500d\u7cbe\u5ea6\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u300d\u3068\u3082\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<p>\u540d\u524d\u304c<span>&#8220;double&#8221;<\/span>\u306a\u306e\u306f\u3001\u4f55\u304b\u306e\u300c\u4e8c\u500d\u300d\u3060\u304b\u3089\u3067\u3059\u3002\u305d\u306e\u4f55\u304b\u3068\u306f\u3001\u540c\u3058\u57fa\u672c\u30c7\u30fc\u30bf\u578b\u3067\u3042\u308b<span>32<\/span>\u30d3\u30c3\u30c8<span>(4<\/span>\u30d0\u30a4\u30c8<span>)<\/span>\u306e<span>float<\/span>\u3067\u3059\u3002<span>double<\/span>\u3067\u306f<span>float<\/span>\u306e\u500d\u306e\u30d3\u30c3\u30c8\u6570\u3092\u4f7f\u3063\u3066\u3001<span>float<\/span>\u3088\u308a\u3082\u305a\u3063\u3068\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u8868\u73fe\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u300c\u6d6e\u52d5\u300d\u5c0f\u6570\u70b9\u6570\u3068\u547c\u3070\u308c\u308b\u306e\u306f\u3001\u6570\u5b57\u306e\u6574\u6570\u90e8\u3068\u5c0f\u6570\u90e8\u306e\u9577\u3055\u304c\u53ef\u5909\u306a\u306e\u3067\u3001\u5c0f\u6570\u70b9\u306e\u4f4d\u7f6e\u304c\u6570\u5b57\u306b\u5408\u308f\u305b\u3066\u3075\u308f\u3075\u308f\u79fb\u52d5\u3059\u308b\u304b\u3089\u3067\u3059\u3002\u4e00\u65b9\u3067\u3001\u56fa\u5b9a\u5c0f\u6570\u70b9\u6570\u3068\u3044\u3046\u3082\u306e\u3082\u6570\u5024\u8a08\u7b97\u306e\u4e16\u754c\u306b\u306f\u3042\u308a\u307e\u3059\u304c\u3001<span>Java<\/span>\u306e<span>double\/float<\/span>\u306f\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u3067\u3059\u3002<\/p>\n<p>double\u3092\u4ed6\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u7c21\u5358\u306b\u6bd4\u8f03\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<span>double<\/span>\u3067\u306f\u3001\u3082\u3063\u3068\u3082\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u6271\u3048\u308b\u3053\u3068\u304c\u5206\u304b\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u30c7\u30fc\u30bf\u578b<\/th>\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u5024\u306e\u7a2e\u985e<\/th>\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u30d3\u30c3\u30c8\u6570<\/th>\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u8868\u73fe\u3067\u304d\u308b\u5024\u306e\u7bc4\u56f2<\/th>\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u63a5\u5c3e\u8a9e<\/th>\n<th style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u5099\u8003<\/th>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">boolean<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u771f\u507d\u5024<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">1\u30d3\u30c3\u30c8<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">true\/false\u306e\u3069\u3061\u3089\u304b<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">&#8211;<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">byte<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6574\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">8\u30d3\u30c3\u30c8(1\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">-128\uff5e<span>127<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">&#8211;<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">short<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6574\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">16\u30d3\u30c3\u30c8(2\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">-32,768\uff5e<span>32,767<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">&#8211;<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">char<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6587\u5b57<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">16\u30d3\u30c3\u30c8(2\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">0\uff5e<span>65,535<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">&#8211;<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">Unicode\u6587\u5b57\u3001<span>\\u0000<\/span>\uff5e<span>\\uffff<\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">int<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6574\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">32\u30d3\u30c3\u30c8(4\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">-2,147,483,648\uff5e2,147,483,647<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">&#8211;<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u7d04<span>\u00b121<\/span>\u5104<span>4<\/span>\u5343<span>7<\/span>\u767e\u4e07\u3001<span>Unicode<\/span>\u30b3\u30fc\u30c9\u30dd\u30a4\u30f3\u30c8<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">long<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6574\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">64\u30d3\u30c3\u30c8(8\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">-9,223,372,036,854,775,808\uff5e<span>9,223,372,036,854,775,807<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">L\u307e\u305f\u306f<span>l<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u7d04<span>\u00b1922<\/span>\u4eac<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">float<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">32\u30d3\u30c3\u30c8(4\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u00b13.40282347E+38\uff5e <span>1.40239846E-45<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">F\u307e\u305f\u306f<span>f<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u5358\u7cbe\u5ea6<br \/>\n\u7d04<span>\u00b13.4\u00d710<\/span>\u306e<span>38<\/span>\u4e57\uff5e\u7d04<span>\u00b11.4\u00d710<\/span>\u306e<span>-45<\/span>\u4e57<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">double<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">64\u30d3\u30c3\u30c8(8\u30d0\u30a4\u30c8)<\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u00b11.79769313486231570E+308\uff5e<span>\u00b14.94065645841246544E-324<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">D\u307e\u305f\u306f<span>d<\/span><\/td>\n<td style=\"width: 16.6667%; border-color: #000000; height: 24px;\">\u500d\u7cbe\u5ea6<br \/>\n\u7d04<span>\u00b11.8\u00d710<\/span>\u306e<span>308<\/span>\u4e57\uff5e\u7d04<span>\u00b14.9\u00d710<\/span>\u306e<span>-324<\/span>\u4e57<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span id=\"-double\">\uff11-\uff11\uff0edouble\u306f\u6307\u6570\u8868\u8a18\u3067\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u8868\u73fe\u3059\u308b<\/span><\/h3>\n<p>double\u306f\u3001\u3082\u306e\u3059\u3054\u304f\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u8868\u73fe\u3067\u304d\u307e\u3059\u3002\u524d\u8ff0\u306e\u8868\u306b\u3082\u3042\u308b\u3068\u304a\u308a\u3001<span>10<\/span>\u306e<span>308<\/span>\u4e57\u3068\u3044\u3046\u3061\u3087\u3063\u3068\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u5927\u304d\u3055\u306e\u6570\u5b57\u3084\u3001<span>10<\/span>\u306e\u30de\u30a4\u30ca\u30b9<span>324<\/span>\u4e57\u3068\u3044\u3046\u3053\u308c\u307e\u305f\u3059\u3054\u3044\u5c0f\u3055\u306a\u6570\u5b57\u3092\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ \u304b\u306a\u308a\u5927\u304d\u3044\u6570\u5b57\u3068\u5c0f\u3055\u3044\u6570\u5b57\u3001\u3067\u3082double\u3067\u306f\u307e\u3063\u305f\u304f\u3082\u3063\u3066\u4f59\u88d5!!\r\ndouble tooBig = 1000000000000000000000000000000D;\r\ndouble tooSmall = 0.00000000000000000000000000001;<\/pre>\n<p>\u3053\u308c\u307b\u3069\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u3092\u8868\u73fe\u3067\u304d\u308b\u306e\u306f\u3001<span>double<\/span>\u306f\u5185\u90e8\u3067\u300c\u6307\u6570\u8868\u8a18\u300d\u3092\u4f7f\u3046\u304b\u3089\u3067\u3059\u3002\u6307\u6570\u8868\u8a18\u3067\u306f\u7b26\u53f7\u3001\u4eee\u6570\u3001\u57fa\u6570\u3001\u6307\u6570\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u6570\u5b57\u3092\u8868\u73fe\u3057\u307e\u3059\u304c\u3001<span>double<\/span>\u306e<span>64<\/span>\u30d3\u30c3\u30c8\u306e\u7bc4\u56f2\u3092\u7b26\u53f7\u3001\u4eee\u6570\u3001\u6307\u6570\u305d\u308c\u305e\u308c\u306b\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/96225dc21133a5837a616390b0facde6.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/96225dc21133a5837a616390b0facde6.png\" alt=\"\u6307\u6570\u8868\u8a18\u306e\u8003\u3048\u65b9\" width=\"960\" height=\"720\" class=\"alignnone size-full wp-image-1549\" srcset=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/96225dc21133a5837a616390b0facde6.png 960w, https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/96225dc21133a5837a616390b0facde6-768x576.png 768w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<p>\u4f8b\u3048\u3070\u3001<span>123,000<\/span>\u306f\u300c<span>1.23\u00d710<\/span>\u306e<span>5<\/span>\u4e57\u300d\u3067\u3059\u3002<span>0.0000123<\/span>\u3082\u540c\u69d8\u306b\u300c<span>1.23\u00d710<\/span>\u306e<span>-5<\/span>\u4e57\u300d\u3067\u3059\u3002\u4e21\u65b9\u3068\u3082<span>1.23\u00d710<\/span>\u306e\u4f55\u4e57\u3068\u8a00\u3063\u3066\u3044\u308b\u3060\u3051\u3067\u3001\u9055\u3046\u306e\u306f<span>10<\/span>\u306e\u4e57\u6570\u3060\u3051\u3067\u3059\u3002<span>double<\/span>\u3067\u306f\u5927\u304d\u306a\u6570\u5b57\u3082\u5c0f\u3055\u306a\u6570\u5b57\u3082\u3053\u306e\u3088\u3046\u306b\u8a00\u3044\u63db\u3048\u3066\u3001\u30d3\u30c3\u30c8\u3092\u52b9\u7387\u7684\u306b\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double moreTooBig = 1.0e308; \/\/ 1.0\u00d710\u306e308\u4e57\r\ndouble moreTooSmall = 5.0e-324; \/\/ 5.0\u00d710\u306e-324\u4e57<\/pre>\n<h3><span id=\"-double-2\">\uff11-\uff12\uff0edouble\u306f\u8aa4\u5dee\u3068\u4e00\u84ee\u6258\u751f<\/span><\/h3>\n<p>double\u3092\u4f7f\u3046\u3068\u3001\u5e83\u3044\u7bc4\u56f2\u306e\u6570\u5b57\u306e\u8a08\u7b97\u3092\u9ad8\u901f\u306b\u884c\u3048\u307e\u3059\u3002\u3067\u3059\u304c\u3001\u305d\u306e\u9ad8\u901f\u3055\u306f\u5e38\u306b\u8aa4\u5dee\u3068\u5f15\u304d\u63db\u3048\u3067\u3059\u3002\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3067\u306e\u6570\u5024\u8a08\u7b97\u306f\u3001\u6614\u3082\u4eca\u3082\u3053\u308c\u304b\u3089\u3082\u3001\u8aa4\u5dee\u3068\u306e\u6226\u3044\u3067\u3059\u3002\u3067\u3059\u304b\u3089\u3001\u8aa4\u5dee\u306f<span>double<\/span>\u3092\u4f7f\u3046\u4e0a\u3067\u306f\u3044\u3064\u3082\u610f\u8b58\u3057\u3066\u304a\u304d\u305f\u3044\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>double\u306e\u3088\u3046\u306a\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u304c\u82e6\u624b\u3068\u3059\u308b\u306e\u306f\u3001\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6570\u5b57\u3092\u6b63\u78ba\u306b\u8868\u73fe\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u306f\u5927\u4e8b\u306a\u3053\u3068\u306a\u306e\u3067\u5fc5\u305a\u899a\u3048\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<span>double<\/span>\u3067\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6570\u5b57\u3092\u6271\u3046\u3068\u3001<span>double<\/span>\u304c<span>64<\/span>\u30d3\u30c3\u30c8\u3082\u3042\u308b\u3068\u306f\u3044\u3048\u9650\u3089\u308c\u305f\u30d3\u30c3\u30c8\u6570\u3057\u304b\u6301\u3063\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u8aa4\u5dee\u304c\u3069\u3046\u3057\u3066\u3082\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h4>\uff11-\uff12-\uff11\uff0e\u8aa4\u5dee\u306e\u4f8b\uff1a<span>0.1<\/span>\u3092<span>10<\/span>\u56de\u8db3\u3057\u3066\u307f\u308b<\/h4>\n<p>\u4f8b\u3048\u3070\u3001\u5b9f\u306f<span>double<\/span>\u3067\u306f<span>0.1<\/span>\u3059\u3089\u6b63\u78ba\u306b\u8868\u305b\u307e\u305b\u3093\u3002\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3001<span>double<\/span>\u306e<span>0.1<\/span>\u3092<span>10<\/span>\u56de\u8db3\u3057\u3066\u3082<span>1<\/span>\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3067\u306f<span>&#8220;0.1&#8221;<\/span>\u3068\u660e\u78ba\u306b\u66f8\u3044\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u306e<span>double<\/span>\u304c\u8868\u3057\u3066\u3044\u308b\u6570\u5b57\u306f\u3001<span>0.1<\/span>\u3068\u306f\u307b\u3093\u306e\u3061\u3087\u3063\u3068\u3060\u3051\u9055\u3046\u6570\u5b57\u306a\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double diff = 0.1;\r\ndouble sum = 0;\r\n\r\nfor (int i = 0; i &lt; 10; i++) {\r\n\tsum += diff;\r\n}\r\n\r\nSystem.out.println(sum); \/\/ \u2192 0.9999999999999999\r\nSystem.out.println(sum == 1); \/\/ \u2192 false<\/pre>\n<p>\u3053\u306e<span>0.1<\/span>\u3068\u306e\u8aa4\u5dee\u306f\u3001\u4e38\u3081\u8aa4\u5dee\u3068\u3044\u3046\u3082\u306e\u304c\u5f71\u97ff\u3057\u3066\u3044\u307e\u3059\u3002<span>double<\/span>\u3067\u306f\u3001\u3053\u306e\u4ed6\u306b\u3082\u3044\u308d\u3044\u308d\u306a\u8a08\u7b97\u4e0a\u306e\u8aa4\u5dee\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u8aa4\u5dee\u306e\u7a2e\u985e\u306f\u3042\u3068\u3067\u7c21\u5358\u306b\u7d39\u4ecb\u3057\u307e\u3059\u304c\u3001\u3069\u3046\u306b\u3082\u8a08\u7b97\u7d50\u679c\u304c\u5f0f\u3068\u5408\u308f\u306a\u3044\u306a\u3001\u3068\u3044\u3046\u6642\u306f\u8a08\u7b97\u8aa4\u5dee\u3092\u7591\u3044\u307e\u3057\u3087\u3046\u3002\u8a08\u7b97\u8aa4\u5dee\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3082\u3044\u308d\u3044\u308d\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"-Javadouble\">\uff11-\uff13\uff0eJava\u306e<span>double<\/span>\u306f\u56fd\u969b\u6a19\u6e96\u898f\u683c\u6e96\u62e0<\/span><\/h3>\n<p>Java\u306e<span>double<\/span>\u306f\u3001\u56fd\u969b\u7684\u306a\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u306e\u6a19\u6e96\u898f\u683c\u300c<span>IEEE 754<\/span>\u300d\u306b\u6e96\u62e0\u3057\u3066\u3044\u307e\u3059\u3002\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3082<span>IEEE 754<\/span>\u306b\u6e96\u62e0\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u666e\u901a\u306a\u306e\u3067\u3001<span>double<\/span>\u3067\u306e\u8a08\u7b97\u7d50\u679c\u306f\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u306e\u5b9f\u884c\u7d50\u679c\u3068\u6982\u306d\u4e00\u81f4\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\u3010\u53c2\u8003\u3011IEEE 754<\/p>\n<p><a href=\"https:\/\/ja.wikipedia.org\/wiki\/IEEE_754\">https:\/\/ja.wikipedia.org\/wiki\/IEEE_754<\/a><\/p>\n<\/blockquote>\n<p>IEEE 754\u3067\u306f\u3001<span>64<\/span>\u30d3\u30c3\u30c8\u4e2d\u306e\u3069\u306e\u90e8\u5206\u3092\u7b26\u53f7\u3001\u4eee\u6570\u3001\u6307\u6570\u306b\u4f7f\u3046\u304b\u3084\u3001\u8a08\u7b97\u30eb\u30fc\u30eb\u304c\u6c7a\u3081\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u3044\u308d\u3044\u308d\u306a\u7406\u7531\u3084\u7d4c\u7def\u304c\u3042\u308a\u3001\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u3092\u4f5c\u308b\u306b\u3082\u5c11\u3005\u8a08\u7b97\u304c\u5fc5\u8981\u3067\u3059\u304c\u3001<span>double<\/span>\u3092\u4f7f\u3046\u5074\u306f\u305d\u308c\u3092\u5f37\u304f\u610f\u8b58\u3057\u306a\u304f\u3066\u3082<span>OK<\/span>\u3067\u3059\u3002\u306a\u304a\u3001<span>double<\/span>\u306e\u57fa\u6570\u306f<span>2<\/span>\u56fa\u5b9a\u306a\u306e\u3067\u3001\u3053\u306e<span>64<\/span>\u30d3\u30c3\u30c8\u4e2d\u306b\u57fa\u6570\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/9e2ee97242c53ecbb35c4adc7d0d7154.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/9e2ee97242c53ecbb35c4adc7d0d7154.png\" alt=\"\u500d\u7cbe\u5ea6\u6d6e\u52d5\u5c0f\u6570\u70b9\" width=\"960\" height=\"720\" class=\"alignnone size-full wp-image-1550\" srcset=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/9e2ee97242c53ecbb35c4adc7d0d7154.png 960w, https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/9e2ee97242c53ecbb35c4adc7d0d7154-768x576.png 768w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<h2><span id=\"double\">\uff12\uff0edouble\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/span><\/h2>\n<p>\u3053\u3053\u3067\u306f\u3001<span>double<\/span>\u306e\u4f7f\u3044\u65b9\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001<span>double<\/span>\u3092\u4f7f\u3046\u4e0a\u3067\u306f\u6ce8\u610f\u3059\u3079\u304d\u3053\u3068\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u305d\u308c\u3089\u3082\u9806\u756a\u306b\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"-double-3\">\uff12-\uff11\uff0edouble\u306e\u5ba3\u8a00\u306e\u4ed5\u65b9\u3001\u521d\u671f\u5024\u3001\u30ea\u30c6\u30e9\u30eb<\/span><\/h3>\n<h4>\uff12-\uff12-\uff11\uff0edouble\u306e\u5909\u6570\u30fb\u914d\u5217\u306e\u5ba3\u8a00\u3001\u521d\u671f\u5024\u306e\u6307\u5b9a<\/h4>\n<p>double\u306f\u578b\u306e\u4e00\u3064\u3067\u3059\u304b\u3089\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u6570\u3084\u914d\u5217\u5909\u6570\u306e\u578b\u3068\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002\u3082\u3061\u308d\u3093\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u3084\u3001\u623b\u308a\u5024\u3068\u3057\u3066\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ double\u578b\u306e\u5909\u6570\u306e\u5ba3\u8a00\u3068\u3001\u521d\u671f\u5024\u306e\u4ee3\u5165\r\ndouble d = 12345.789;\r\n\r\n\/\/ double\u578b\u306e\u914d\u5217\u306e\u5ba3\u8a00\u3068\u3001\u5404\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3078\u306e\u5024\u306e\u4ee3\u5165\r\ndouble[] darr = new double[3];\r\ndarr[0] = 1.1;\r\ndarr[1] = -2.2;\r\ndarr[2] = 3.3;<\/pre>\n<h4>\uff12-\uff11-\uff12\uff0edouble\u306e\u30ea\u30c6\u30e9\u30eb\u306e\u66f8\u304d\u65b9<\/h4>\n<p>double\u306e\u5909\u6570\u3078\u4ee3\u5165\u3067\u304d\u308b\u6570\u5b57\u306e\u30ea\u30c6\u30e9\u30eb<span>(<\/span>\u6587\u5b57\u3069\u304a\u308a\u306e\u3001\u3068\u3044\u3046\u610f\u5473<span>)<\/span>\u306f\u3001\u4ee5\u4e0b\u306e\u3044\u305a\u308c\u304b\u306e\u5f62\u5f0f\u3067\u66f8\u3051\u307e\u3059\u3002\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6570\u5b57\u3092\u66f8\u3051\u308b\u306e\u304c\u3001<span>int<\/span>\u306a\u3069\u306e\u6574\u6570\u3068\u306f\u9055\u3044\u307e\u3059\u306d\u3002<span>Java<\/span>\u3067\u306f\u5c0f\u6570\u70b9\u304c\u3042\u308b\u6570\u5b57\u3092\u66f8\u304f\u3068\u3001\u81ea\u52d5\u7684\u306b<span>double<\/span>\u6271\u3044\u306b\u306a\u308a\u307e\u3059\u3002<span>&#8220;_&#8221;<\/span>\u3067\u306e\u6841\u533a\u5207\u308a\u3082\u3067\u304d\u307e\u3059<span>(Java 7<\/span>\u4ee5\u964d<span>)<\/span>\u3002<\/p>\n<ul>\n<li><span>10<\/span>\u9032\u6570<span>(<\/span>\u6574\u6570\u3001\u5c0f\u6570<span>)<\/span><\/li>\n<li><span>10<\/span>\u9032\u6570<span>+<\/span>\u6307\u6570\u8868\u8a18<\/li>\n<li><span>2<\/span>\u9032\u6570<span>(0b<\/span>\u59cb\u307e\u308a\u3001\u6574\u6570<span>)<\/span>\u3001<span>Java 7<\/span>\u4ee5\u964d<\/li>\n<li><span>8<\/span>\u9032\u6570<span>(0<\/span>\u59cb\u307e\u308a\u3001\u6574\u6570<span>)<\/span><\/li>\n<li><span>16<\/span>\u9032\u6570<span>(0x<\/span>\u59cb\u307e\u308a\u3001\u6574\u6570<span>)<\/span><\/li>\n<li><span>16<\/span>\u9032\u6570<span>+<\/span>\u6307\u6570\u8868\u8a18<\/li>\n<\/ul>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ 10\u9032\u6570\u306e\u5c0f\u6570\u70b9\u3042\u308a\u306e\u6570\u5b57\u3068\u30012\u9032\u6570\u30fb8\u9032\u6570\u30fb16\u9032\u6570\u306e\u6574\u6570\r\ndouble d1 = 12345; \/\/ 10\u9032\u6570(\u6574\u6570)\r\ndouble d2 = 1.2345; \/\/ 10\u9032\u6570(\u5c0f\u6570\u70b9\u4ee5\u4e0b\u3042\u308a)\r\ndouble d3 = -123_456.789_012; \/\/ 10\u9032\u6570\u3001\u533a\u5207\u308a\u6587\u5b57\u3042\u308a\r\ndouble d4 = 0b0101; \/\/ 2\u9032\u6570\u306e\u6574\u6570\r\ndouble d5 = 012345; \/\/ 8\u9032\u6570\u306e\u6574\u6570\r\ndouble d6 = 0x12345; \/\/ 16\u9032\u6570\u306e\u6574\u6570<\/pre>\n<p>\u3068\u3066\u3082\u5927\u304d\u3044\u3001\u307e\u305f\u306f\u5c0f\u3055\u3044\u6570\u5b57\u3092\u8868\u3059\u306a\u3089\u3001\u6307\u6570\u8868\u8a18\u3082\u4f7f\u3048\u307e\u3059\u3002\u6307\u6570\u8868\u8a18\u306b\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b<span>double<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u6307\u6570\u8868\u8a18\u306f\u524d\u8ff0\u306e\u3068\u304a\u308a\u7b26\u53f7\u3001\u4eee\u6570\u3001\u6307\u6570\u306e\u7d44\u307f\u5408\u308f\u305b\u306a\u306e\u3067\u3001\u30ea\u30c6\u30e9\u30eb\u3067\u3082\u540c\u69d8\u306b\u66f8\u304d\u307e\u3059\u3002\u6307\u6570\u8868\u8a18\u3067\u306e<span>double<\/span>\u306e\u57fa\u6570\u306f\u3001<span>10(e)<\/span>\u3068<span>2(p)<\/span>\u3092\u9078\u3079\u3066\u3001<span>10<\/span>\u9032\u6570\u3068<span>16<\/span>\u9032\u6570\u3078\u3060\u3051\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/93dc263ad3e40027f7378e886e15c5cd.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/93dc263ad3e40027f7378e886e15c5cd.png\" alt=\"\u6307\u6570\u8868\u8a18\u306e\u4f8b\" width=\"960\" height=\"720\" class=\"alignnone size-full wp-image-1551\" srcset=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/93dc263ad3e40027f7378e886e15c5cd.png 960w, https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2019\/03\/93dc263ad3e40027f7378e886e15c5cd-768x576.png 768w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ 10\u9032\u6570\u306816\u9032\u6570\u306e\u6307\u6570\u8868\u8a18\r\ndouble d1 = 1.23e4; \/\/ 10\u9032\u6570 \u6307\u6570\u8868\u8a18(1.23\u00d710\u306e4\u4e57) \u2192 12300\r\ndouble d2 = -1.23e-4; \/\/ 10\u9032\u6570 \u6307\u6570\u8868\u8a18(-1.23\u00d710\u306e-4\u4e57) \u2192 -0.000123\r\ndouble d3 = 0x1.23p4; \/\/ 16\u9032\u6570 \u6307\u6570\u8868\u8a18(0x1.23\u00d72\u306e4\u4e57) \u2192 18.1875\r\ndouble d4 = -0x1.23p-4; \/\/ 16\u9032\u6570 \u6307\u6570\u8868\u8a18(-0x1.23\u00d72\u306e-4\u4e57) \u2192 -0.071044921875<\/pre>\n<p>\u30ea\u30c6\u30e9\u30eb\u304c<span>double<\/span>\u3060\u3068\u660e\u793a\u7684\u306b\u8868\u73fe\u3057\u305f\u3044\u306a\u3089\u3001\u63a5\u5c3e\u8a9e\u3068\u3057\u3066<span>D<\/span>\u3042\u308b\u3044\u306f<span>d<\/span>\u3092\u4ed8\u3051\u3066\u300c\u3053\u308c\u306f<span>double<\/span>\u3060\u3088\u300d\u3068<span>Java<\/span>\u306b\u6559\u3048\u307e\u3059\u3002\u5c0f\u6570\u70b9\u4ee5\u4e0b\u304c\u306a\u3044\u6570\u5024\u30ea\u30c6\u30e9\u30eb\u306f\u3001<span>Java<\/span>\u3067\u306f\u81ea\u52d5\u7684\u306b<span>int<\/span>\u306b\u306a\u308b\u306e\u3067\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ \u63a5\u5c3e\u8a9e\u3068\u3057\u3066d\/D\u3092\u4ed8\u3051\u308c\u3070\u3001\u305d\u306e\u30ea\u30c6\u30e9\u30eb\u306fdouble\u6271\u3044\u306b\u306a\u308b\r\ndouble d1 = 5 \/ 10; \/\/ \u2192 0\u3001int\u306e5\u3092int\u306e10\u3067\u5272\u308b\u306e\u3067\u3001\u8a08\u7b97\u7d50\u679c\u306fint\u306e0\u306b\u306a\u308b\r\ndouble d2 = 5 \/ 10d; \/\/ \u2192 0.5\u3001int\u306e5\u3092double\u306e10\u3067\u5272\u308b\u306e\u3067\u30015\u3082double\u306b\u306a\u308a\u3001\u8a08\u7b97\u7d50\u679c\u306fdouble\u306e0.5\u306b\u306a\u308b<\/pre>\n<p>\u306a\u304a\u3001double\u306b\u306f\u6b63\u8ca0\u306e\u7121\u9650\u5927(Inifinity)\u3084\u975e\u6570(NaN\u3001Not a Number)\u306a\u3069\u306e\u3001\u7279\u6b8a\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001<span>0<\/span>\u306b\u3082\u6b63\u8ca0\u306e<span>0(+0.0<\/span>\u3001<span>-0.0)<\/span>\u304c\u3042\u3063\u3066\u533a\u5225\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u3089\u306f<span>IEEE 754<\/span>\u3067\u6c7a\u3081\u3089\u308c\u3066\u3044\u308b\u3082\u306e\u3067\u3001\u666e\u901a\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u610f\u8b58\u3059\u308b\u3053\u3068\u306f\u3042\u307e\u308a\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3042\u308b\u3053\u3068\u306f\u77e5\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = Double.POSITIVE_INFINITY;\r\ndouble d2 = Double.NEGATIVE_INFINITY;\r\ndouble d3 = Double.NaN;\r\ndouble d4 = +0.0;\r\ndouble d5 = -0.0;<\/pre>\n<h4>\uff12-\uff11-\uff13\uff0edouble\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3001\u914d\u5217\u306e\u521d\u671f\u5024\u306f<span>0.0<\/span><\/h4>\n<p>\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u3057\u3066<span>double<\/span>\u578b\u306e\u5909\u6570\u3092\u4f7f\u3063\u305f\u308a\u3001<span>double<\/span>\u578b\u306e\u914d\u5217\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001\u672a\u521d\u671f\u5316\u3060\u3068<span>0.0<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u4ed6\u306e\u6570\u5024\u578b\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">class DoubleTest {\r\n\tdouble d; \/\/ double\u3092\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3057\u305f\u304c\u3001\u521d\u671f\u5024\u306f\u672a\u8a2d\u5b9a\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tDoubleTest doubleTest = new DoubleTest();\r\n\t\tSystem.out.println(doubleTest.d); \/\/ \u2192 0.0\u3001\u5909\u6570\u5ba3\u8a00\u6642\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u8a2d\u5b9a\u3055\u308c\u308b\r\n\r\n\t\tdouble[] array = new double[5];\r\n\t\tSystem.out.prdoubleln(array[0]); \/\/ \u2192 0.0\u3001new\u3057\u305f\u6642\u70b9\u3067\u914d\u5217\u5168\u4f53\u304c0.0\u3067\u521d\u671f\u5316\u3055\u308c\u308b\r\n\t}\r\n}<\/pre>\n<h3><span id=\"-double-4\">\uff12-\uff12\uff0edouble\u3092\u4f7f\u3063\u305f\u56db\u5247\u6f14\u7b97<\/span><\/h3>\n<h4>\uff12-\uff12-\uff11\uff0edouble\u304c\u7d61\u3080\u3068\u8a08\u7b97\u7d50\u679c\u306f<span>double<\/span>\u306b\u306a\u308b<\/h4>\n<p>double\u3092\u4f7f\u3063\u305f\u56db\u5247\u6f14\u7b97<span>(<\/span>\u52a0\u6e1b\u4e57\u9664<span>)<\/span>\u306b\u306f\u3001\u56db\u5247\u6f14\u7b97\u7528\u306e\u7b97\u8853\u6f14\u7b97\u5b50\u3001\u3064\u307e\u308a<span>+-*\/<\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002\u4f59\u308a\u3092\u6c42\u3081\u308b\u306a\u3089<span>%<\/span>\u3067\u3059\u3002\u3067\u3059\u306e\u3067\u3001\u3054\u304f\u76f4\u611f\u7684\u306b\u8a08\u7b97\u3067\u304d\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<span>double<\/span>\u3068\u8a08\u7b97\u3057\u305f\u7d50\u679c\u306f<span>double<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u3082\u3046\u5c11\u3057\u6b63\u78ba\u306b\u8a00\u3048\u3070\u3001<span>double<\/span>\u3068<span>double<\/span>\u3067\u306a\u3044\u3082\u306e\u3067\u8a08\u7b97\u3092\u3059\u308b\u3068\u3001<span>double<\/span>\u3067\u306a\u3044\u3082\u306e\u306e\u65b9\u304c\u81ea\u52d5\u7684\u306b<span>double<\/span>\u306b\u5909\u63db<span>(<\/span>\u30ad\u30e3\u30b9\u30c8<span>)<\/span>\u3055\u308c\u3066\u8a08\u7b97\u3055\u308c\u307e\u3059\u3002<span>double<\/span>\u304c\u95a2\u4fc2\u3059\u308b\u30ad\u30e3\u30b9\u30c8\u306e\u30eb\u30fc\u30eb\u306f\u5f8c\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double i = 10;\r\ndouble j = 3;\r\n\r\ndouble plus = i + j;\r\ndouble minus = i - j;\r\ndouble multiply = i * j;\r\ndouble divide = i \/ j;\r\ndouble surplus = i % j;\r\n\r\nSystem.out.println(plus); \/\/ \u2192 13.0\r\nSystem.out.println(minus); \/\/ \u2192 7.0\r\nSystem.out.println(multiply); \/\/ \u2192 30.0\r\nSystem.out.println(divide); \/\/ \u2192 3.3333333333333335(\u8a08\u7b97\u4e0a\u306f10 \/ 3 = 3.333\u2026\u3060\u304c\u3001\u9014\u4e2d\u3067\u6253\u3061\u5207\u3089\u308c\u3066\u4e38\u3081\u3089\u308c\u308b)\r\nSystem.out.println(surplus); \/\/ \u2192 1.0<\/pre>\n<h4>\uff12-\uff12-\uff12\uff0edouble\u306b\u306f\u7121\u9650\u5927\u3068\u975e\u6570\u304c\u3042\u308b<\/h4>\n<p>\u8a08\u7b97\u3057\u305f\u7d50\u679c\u3001<span>double<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u3088\u308a\u3082\u7d76\u5bfe\u5024\u304c\u5927\u304d\u304f\u306a\u3063\u305f\u306a\u3089\u7121\u9650\u5927<span>(Infinity)<\/span>\u306b\u306a\u308a\u307e\u3059<span>(<\/span>\u3044\u308f\u3086\u308b\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc<span>)<\/span>\u3002<span>double<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u3088\u308a\u3082\u7d76\u5bfe\u5024\u304c\u5c0f\u3055\u304f\u306a\u3063\u305f\u306a\u3089<span>0.0<\/span>\u306b\u306a\u308a\u307e\u3059<span>(<\/span>\u3044\u308f\u3086\u308b\u30a2\u30f3\u30c0\u30fc\u30d5\u30ed\u30fc<span>)<\/span>\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = Double.MAX_VALUE;\r\ndouble d2 = -Double.MAX_VALUE;\r\ndouble d3 = Double.MIN_VALUE;\r\ndouble d4 = -Double.MIN_VALUE;\r\n\r\ndouble d5 = d1 * 2; \/\/ double\u306e\u6700\u5927\u5024\u30922\u500d\u3057\u3066\u307f\u308b\r\ndouble d6 = d2 * 2;\r\ndouble d7 = d3 \/ 1000; \/\/ double\u3067\u7d76\u5bfe\u5024\u304c\u6700\u3082\u5c0f\u3055\u306a\u5024\u30921000\u5206\u306e1\u306b\u3057\u3066\u307f\u308b\r\ndouble d8 = d4 \/ 1000;\r\n\r\nSystem.out.println(d5); \/\/ \u2192 Infinty\r\nSystem.out.println(d6); \/\/ \u2192 -Infinty\r\nSystem.out.println(d7); \/\/ \u2192 0.0\r\nSystem.out.println(d8); \/\/ \u2192 -0.0<\/pre>\n<p>\u975e\u6570<span>(NaN)<\/span>\u306f\u3069\u3093\u306a\u6570\u5b57\u3068\u3069\u3093\u306a\u8a08\u7b97\u3092\u3057\u3066\u3082<span>NaN<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u52d5\u304d\u306f\u3001<span>SQL<\/span>\u3067\u306e<span>NULL<\/span>\u3068\u4f3c\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = Double.NaN + 1;\r\ndouble d2 = Double.NaN * 100;\r\ndouble d3 = Double.NaN + Double.POSITIVE_INFINITY;\r\ndouble d4 = Double.NaN + Double.NaN;\r\n\r\nSystem.out.println(d1); \/\/ \u2192 NaN\r\nSystem.out.println(d2); \/\/ \u2192 NaN\r\nSystem.out.println(d3); \/\/ \u2192 NaN\r\nSystem.out.println(d4); \/\/ \u2192 NaN<\/pre>\n<p>double\u3067\u306f\u3001<span>0<\/span>\u3067\u306e\u5272\u308a\u7b97<span>(<\/span>\u3044\u308f\u3086\u308b<span>0<\/span>\u9664\u7b97<span>)<\/span>\u3092\u884c\u3063\u3066\u3082<span>ArithmeticException<\/span>\u306f<span>throw<\/span>\u3055\u308c\u307e\u305b\u3093\u3002\u5272\u3089\u308c\u308b\u6570\u306b\u3088\u308a\u7d50\u679c\u306f\u9055\u3044\u3001<span>Infinity<\/span>\u3084<span>NaN<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u7d50\u679c\u306f\u3001<span>NaN<\/span>\u3084<span>Infinity<\/span>\u3078\u306e\u8a08\u7b97\u3082\u542b\u3081\u3001\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u306e\u8a08\u7b97\u30eb\u30fc\u30eb\u3067\u6c7a\u3081\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.0 \/ 0.0;\r\ndouble d2 = 0.0 \/ 0.0;\r\ndouble d3 = Double.POSITIVE_INFINITY - 1;\r\ndouble d4 = Double.POSITIVE_INFINITY * 0;\r\n\r\nSystem.out.println(d1); \/\/ \u2192 Infinity\r\nSystem.out.println(d2); \/\/ \u2192 NaN\r\nSystem.out.println(d3); \/\/ \u2192 Infinity\r\nSystem.out.println(d4); \/\/ \u2192 NaN<\/pre>\n<h3><span id=\"-double-5\">\uff12-\uff13\uff0edouble\u3068\u30d3\u30c3\u30c8\u6f14\u7b97<\/span><\/h3>\n<p>double\u3078\u306f\u76f4\u63a5\u30d3\u30c3\u30c8\u6f14\u7b97\u3092\u884c\u3048\u307e\u305b\u3093\u3002<span>Java<\/span>\u3067\u306e\u30d3\u30c3\u30c8\u6f14\u7b97\u306f\u3001<span>int<\/span>\u306a\u3069\u306e\u6574\u6570\u578b\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u304b<span>boolean<\/span>\u306b\u3060\u3051\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u8a08\u7b97\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.0;\r\ndouble d2 = -1.0;\r\nlong l = d1 &amp; d2; \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! \u300c\u6f14\u7b97\u5b50 &amp; \u306f\u5f15\u6570\u306e\u578b double, double \u3067\u672a\u5b9a\u7fa9\u3067\u3059\u300d<\/pre>\n<p>\u3069\u3046\u3057\u3066\u3082<span>double<\/span>\u304c\u6301\u3064\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u3078\u30d3\u30c3\u30c8\u6f14\u7b97\u3092\u884c\u3044\u305f\u3044\u306a\u3089\u3001<span>Double.doubleToLongBits<\/span>\u3042\u308b\u3044\u306f<span>doubleToRawLongBits<\/span>\u3092\u4f7f\u3063\u3066<span>long<\/span>\u306b\u5909\u63db\u3057\u3066\u304b\u3089\u884c\u3044\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001<span>long<\/span>\u306e\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u304b\u3089<span>double<\/span>\u306b\u5909\u63db\u3059\u308b\u306b\u306f\u3001<span>Double.longBitsToDouble<\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.0;\r\ndouble d2 = -1.0;\r\n\r\nlong l1 = Double.doubleToLongBits(d1); \/\/ \u2192 0x3ff0000000000000\r\nlong l2 = Double.doubleToLongBits(d2); \/\/ \u2192 0xbff0000000000000\r\nlong l = l1 &amp; l2; \/\/ \u2192 4607182418800017408(0x3ff0000000000000)\r\n\r\ndouble d3 = Double.longBitsToDouble(l); \/\/ \u2192 1.0<\/pre>\n<h3><span id=\"-double-6\">\uff12-\uff14\uff0edouble\u540c\u58eb\u306e\u6bd4\u8f03\u306b\u306f\u6c17\u3092\u4ed8\u3051\u3088\u3046<\/span><\/h3>\n<p>double\u540c\u58eb\u3092\u6bd4\u8f03\u3059\u308b\u6642\u306f\u3001\u6bd4\u8f03\u6f14\u7b97\u5b50<span>==<\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002<span>==<\/span>\u3067\u306e\u6bd4\u8f03\u3067\u306f\u3001\u6bd4\u3079\u308b\u6570\u5b57\u540c\u58eb\u304c\u5b8c\u5168\u306b\u4e00\u81f4\u3057\u3066\u3044\u306a\u3051\u308c\u3070<span>true<\/span>\u306b\u306f\u306a\u3089\u305a\u3001\u300c\u5927\u4f53\u540c\u3058\u300d\u3068\u306f\u5224\u65ad\u3057\u3066\u306f\u304f\u308c\u307e\u305b\u3093\u3002<span>==<\/span>\u304c\u6b63\u78ba\u306b\u6bd4\u8f03\u3059\u308b\u306e\u306f\u5f53\u305f\u308a\u524d\u306e\u3088\u3046\u306b\u601d\u3048\u307e\u3059\u304c\u3001\u3053\u308c\u304c<span>double<\/span>\u3092\u4f7f\u3046\u4e0a\u3067\u306f\u601d\u308f\u306c\u7f60\u306b\u306a\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.23456789;\r\ndouble d2 = 1.23456789;\r\ndouble d3 = 1.2345678900001;\r\ndouble d4 = 1.2345678900000;\r\n\r\nSystem.out.println(d1 == d2); \/\/ \u2192 true\r\nSystem.out.println(d1 == d3); \/\/ \u2192 false\r\nSystem.out.println(d1 == d4); \/\/ \u2192 true<\/pre>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u3001\u672c\u5f53\u306b\u3054\u304f\u308f\u305a\u304b\u3057\u304b\u6570\u5b57\u304c\u9055\u308f\u306a\u3044<span>double<\/span>\u540c\u58eb\u3067\u3059\u304c\u3001\u305d\u308c\u3067\u3082<span>==<\/span>\u306e\u7d50\u679c\u306f<span>false<\/span>\u3067\u3059\u3002\u5b9f\u969b\u306e\u6570\u5024\u8a08\u7b97\u3067\u306f\u3001\u8a08\u7b97\u5f0f\u306e\u4e0a\u3067\u306f\u5024\u304c\u4e00\u81f4\u3059\u308b\u306f\u305a\u3060\u3051\u308c\u3069\u3082\u3001\u3044\u308d\u3044\u308d\u306a\u8aa4\u5dee\u306b\u3088\u308a\u5b8c\u5168\u306b\u4e00\u81f4\u3057\u306a\u3044\u30b1\u30fc\u30b9\u306f\u666e\u901a\u306b\u3042\u308a\u5f97\u307e\u3059\u3002<span>double<\/span>\u306e\u8a08\u7b97\u7d50\u679c\u306f\u975e\u5e38\u306b\u7d30\u304b\u3044\u6570\u5b57\u306b\u306a\u308a\u3046\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 0.0e-300; \/\/ 0\u305d\u306e\u3082\u306e\r\ndouble d2 = 0.1e-300; \/\/ 0\u306b\u3082\u306e\u3059\u3054\u304f\u8fd1\u3044\u304c\u30010\u3067\u306f\u306a\u3044\r\n\r\nSystem.out.println(d1 == d2); \/\/ \u2192 false\r\nSystem.out.println(0.0 == d2); \/\/ \u2192 false<\/pre>\n<p>\u305d\u3046\u3044\u3046\u30b1\u30fc\u30b9\u3067\u306f\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u7bc4\u56f2\u306a\u3089\u6570\u5b57\u306e\u3076\u308c\u306f\u8a31\u5bb9\u3059\u308b\u3053\u3068\u306b\u3057\u3066\u3001\u305d\u306e\u7bc4\u56f2\u5185\u306b\u3042\u308c\u3070\u7b49\u3057\u3044\u3068\u307f\u306a\u3059\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u3046\u3057\u306a\u3044\u3068\u3001\u5b9f\u7528\u4e0a\u306e\u8a08\u7b97\u306b\u652f\u969c\u3092\u304d\u305f\u3059\u3053\u3068\u3082\u3042\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 0.0e-300; \/\/ 0\u305d\u306e\u3082\u306e\r\ndouble d2 = 0.1e-300; \/\/ 0\u306b\u3082\u306e\u3059\u3054\u304f\u8fd1\u3044\u304c\u30010\u3067\u306f\u306a\u3044\r\ndouble d3 = 0.1e-299; \/\/ \u00b1\u3053\u306e\u7bc4\u56f2\u306b\u53ce\u307e\u3063\u3066\u3044\u308c\u3070\u3001\u540c\u3058\u3068\u898b\u306a\u3059\r\n\r\nif ((d1 - d3) &lt;= d2 &amp;&amp; d2 &lt;= (d1 + d3)) {\r\n\tSystem.out.println(\"\u7b49\u3057\u3044\u3068\u307f\u306a\u3059\"); \/\/ \u3053\u3061\u3089!!\r\n} else {\r\n\tSystem.out.println(\"\u7b49\u3057\u3044\u3068\u307f\u306a\u305b\u306a\u3044\");\r\n}<\/pre>\n<h2><span id=\"double-2\">\uff13\uff0edouble\u3068\u4ed6\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u306e\u5909\u63db<\/span><\/h2>\n<p>Java\u3067\u306f\u6570\u5b57\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u3057\u3066\u3001\u6574\u6570(byte\/short\/char\/long)\u3068\u3001\u5c0f\u6570\u70b9\u304c\u6271\u3048\u308b\u3082\u306e(float\/double)\u304c\u3042\u308a\u307e\u3059\u3002double\u3068\u305d\u308c\u3089\u3068\u306e\u5909\u63db\u3084\u6f14\u7b97\u306e\u6642\u306b\u306f\u6ce8\u610f\u3059\u308b\u3053\u3068\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"-doubledouble\">\uff13-\uff11\uff0edouble\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b<span>\u2192double<\/span>\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/span><\/h3>\n<p>double\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u304b\u3089<span>double<\/span>\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u3067\u306f\u3001\u5143\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u304c\u6301\u3063\u3066\u3044\u305f\u6570\u5b57\u304c<span>double<\/span>\u3078\u305d\u306e\u307e\u307e\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002<span>double<\/span>\u306f\u3001<span>Java<\/span>\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3067\u3082\u3063\u3068\u3082\u8868\u73fe\u3067\u304d\u308b\u6570\u5b57\u306e\u7bc4\u56f2\u304c\u5e83\u3044\u306e\u3067\u3001\u3069\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e\u6570\u5b57\u3067\u3082<span>double<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u6574\u6570\u578b\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u540c\u58eb\u306e\u30ad\u30e3\u30b9\u30c8\u306e\u3088\u3046\u306b\u3001\u30ad\u30e3\u30b9\u30c8\u5148\u306e\u578b\u306e\u30b5\u30a4\u30ba\u306e\u5206\u3060\u3051\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u304c\u540c\u3058\u306b\u306a\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">byte b = Byte.MIN_VALUE;\r\nchar c = Character.MAX_VALUE;\r\nshort s = Short.MIN_VALUE;\r\nint i = Integer.MIN_VALUE;\r\nlong l = Long.MIN_VALUE;\r\nfloat f = Float.MIN_VALUE;\r\n\r\ndouble d1 = b; \/\/ \u2192 -128.0\r\ndouble d2 = c; \/\/ \u2192 65535.0\r\ndouble d3 = s; \/\/ \u2192 -32768.0\r\ndouble d4 = i; \/\/ \u2192 -2.147483648E9\r\ndouble d5 = l; \/\/ \u2192 -9.223372036854776E18\r\ndouble d6 = f; \/\/ \u2192 1.401298464324817E-45<\/pre>\n<h3><span id=\"-doubledouble-2\">\uff13-\uff12\uff0edouble\u2192double\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/span><\/h3>\n<p>double\u304b\u3089<span>double<\/span>\u4ee5\u5916\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3078\u306e\u5909\u63db\u306f\u3001\u30d3\u30c3\u30c8\u6570\u304c\u5c11\u306a\u304f\u306a\u308b\u306e\u3067\u5024\u304c\u5909\u308f\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u5909\u63db\u65b9\u6cd5\u306f\u3001\u5909\u63db\u5148\u304c<span>float<\/span>\u304b<span>long<\/span>\u304b\u3001\u305d\u308c\u4ee5\u5916\u304b\u3067\u5c11\u3057\u7570\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>\uff13-\uff12-\uff11\uff0edouble\u2192float\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/h4>\n<p>\u30ad\u30e3\u30b9\u30c8\u5148\u304c<span>float<\/span>\u306e\u5834\u5408\u306f\u3001<span>double<\/span>\u304c\u6301\u3063\u3066\u3044\u308b\u4eee\u6570\u3068\u6307\u6570\u304c<span>float<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u306b\u7e2e\u5c0f\u3055\u308c\u307e\u3059\u3002<span>float<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u3092\u8d85\u3048\u3066\u3044\u308b\u3068<span>\u00b1Infinity<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001<span>double<\/span>\u304c<span>NaN<\/span>\u3084<span>\u00b1Infinity<\/span>\u3060\u3063\u305f\u5834\u5408\u306f\u305d\u306e\u307e\u307e\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = Double.MAX_VALUE;\r\nfloat f1 = (float)d1;\r\nSystem.out.println(f1); \/\/ \u2192 Infinity\r\n\r\ndouble d2 = Double.POSITIVE_INFINITY;\r\nfloat f2 = (float)d2;\r\nSystem.out.println(f2); \/\/ \u2192 Infinity\r\n\r\ndouble d3 = Double.NaN;\r\nfloat f3 = (float)d3;\r\nSystem.out.println(f3); \/\/ \u2192 NaN<\/pre>\n<h4>\uff13-\uff12-\uff12\uff0edouble\u2192long\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/h4>\n<p>\u30ad\u30e3\u30b9\u30c8\u5148\u304c<span>long<\/span>\u306e\u5834\u5408\u306f\u3001<span>double<\/span>\u3067\u8868\u3055\u308c\u3066\u3044\u308b\u6570\u5b57\u306e\u5c0f\u6570\u90e8\u306f\u5207\u308a\u6368\u3066\u3089\u308c\u3001\u6574\u6570\u90e8\u3060\u3051\u3092<span>long<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u5185\u3067\u5909\u63db\u3057\u307e\u3059\u3002<span>long<\/span>\u3067\u8868\u73fe\u3067\u304d\u308b\u7bc4\u56f2\u3092\u8d85\u3048\u3066\u3044\u308b\u5834\u5408\u306f\u3001<span>long<\/span>\u306e<span>\u00b1<\/span>\u306e\u6700\u5927\u5024\u3067\u3059\u3002<span>double<\/span>\u304c<span>\u00b1Inifinity<\/span>\u306a\u3089<span>long<\/span>\u306e\u6700\u5927\u5024\u30fb\u6700\u5c0f\u5024\u306b\u306a\u308a\u3001<span>NaN<\/span>\u306e\u5834\u5408\u306f<span>0<\/span>\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.234e100; \/\/ long\u306e\u7bc4\u56f2\u3092\u5927\u304d\u304f\u8d85\u3048\u308b\u6570\u5b57\r\nlong l1 = (long) d1;\r\nSystem.out.println(l1); \/\/ \u2192 9223372036854775807\u3001Long\u306e\u6700\u5927\u5024\r\n\r\ndouble d2 = Double.MAX_VALUE;\r\nlong l2 = (long) d2;\r\nSystem.out.println(l2); \/\/ \u2192 9223372036854775807\u3001Long\u306e\u6700\u5927\u5024\r\n\r\ndouble d3 = Double.NaN;\r\nlong l3 = (long) d3;\r\nSystem.out.println(l3); \/\/ \u2192 0\r\n\r\ndouble d4 = Double.POSITIVE_INFINITY;\r\nlong l4 = (long) d4;\r\nSystem.out.println(l4); \/\/ \u2192 9223372036854775807\u3001Long\u306e\u6700\u5927\u5024\r\n\r\ndouble d5 = Double.NEGATIVE_INFINITY;\r\nlong l5 = (long) d5;\r\nSystem.out.println(l5); \/\/ \u2192 -9223372036854775808\u3001Long\u306e\u6700\u5c0f\u5024<\/pre>\n<h4>\uff13-\uff12-\uff13\uff0edouble\u2192int\/short\/char\/byte\u3078\u306e\u30ad\u30e3\u30b9\u30c8<\/h4>\n<p>\u30ad\u30e3\u30b9\u30c8\u5148\u304c<span>long<\/span>\u4ee5\u5916\u306e\u6574\u6570\u578b\u30d7\u30ea\u30df\u30c6\u30a3\u30d6<span>(int\/short\/char\/byte)<\/span>\u306e\u5834\u5408\u306f<span>long<\/span>\u306e\u5834\u5408\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u5909\u63db\u5148\u306e\u7bc4\u56f2\u304c<span>int<\/span>\u306b\u306a\u308a\u307e\u3059\u3002\u3055\u3089\u306b\u305d\u306e<span>int<\/span>\u304b\u3089\u305d\u308c\u305e\u308c\u306e\u578b\u306e\u30d3\u30c3\u30c8\u30b5\u30a4\u30ba\u306b\u5fdc\u3058\u305f\u30ad\u30e3\u30b9\u30c8\u304c\u884c\u308f\u308c\u307e\u3059\u3002<span>\u00b1Infinity<\/span>\u3068<span>NaN<\/span>\u306e\u6271\u3044\u306f<span>long<\/span>\u3068\u540c\u3058\u3067\u3059\u3002\u4ee5\u4e0b\u3067\u306f<span>int<\/span>\u3092\u4f8b\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 1.234e100; \/\/ int\u306e\u7bc4\u56f2\u3092\u5927\u304d\u304f\u8d85\u3048\u308b\u6570\u5b57\r\nint i1 = (int) d1;\r\nSystem.out.println(i1); \/\/ \u2192 2147483647\u3001int\u306e\u6700\u5927\u5024\r\n\r\ndouble d2 = Double.MAX_VALUE;\r\nint i2 = (int) d2;\r\nSystem.out.println(i2); \/\/ \u2192 2147483647\u3001int\u306e\u6700\u5927\u5024\r\n\r\ndouble d3 = Double.NaN;\r\nint i3 = (int) d3;\r\nSystem.out.println(i3); \/\/ \u2192 0\r\n\r\ndouble d4 = Double.POSITIVE_INFINITY;\r\nint i4 = (int) d4;\r\nSystem.out.println(i4); \/\/ \u2192 2147483647\u3001int\u306e\u6700\u5927\u5024\r\n\r\ndouble d5 = Double.NEGATIVE_INFINITY;\r\nint i5 = (int) d5;\r\nSystem.out.println(i5); \/\/ \u2192 -2147483648\u3001int\u306e\u6700\u5c0f\u5024<\/pre>\n<h2><span id=\"doubleString\">\uff14\uff0edouble\u3068String\u3068\u306e\u5909\u63db<\/span><\/h2>\n<p>String\u3082double\u3068\u4e26\u3093\u3067Java\u3067\u306f\u91cd\u8981\u306a\u30af\u30e9\u30b9\u3067\u3059\u3002String\u3092<span>double<\/span>\u306b\u3059\u308b\u3053\u3068\u3001\u307e\u305f<span>double<\/span>\u3092<span>String<\/span>\u306b\u3059\u308b\u3053\u3068\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u65e5\u5e38\u8336\u98ef\u4e8b\u3067\u3059\u3002\u3053\u3053\u3067\u306f\u305d\u306e\u65b9\u6cd5\u3092\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"-Stringdouble\">\uff14-\uff11\uff0eString\u2192double\u306e\u5909\u63db<\/span><\/h3>\n<p>\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3060\u6587\u5b57\u5217\u3084\u3001\u5f15\u6570\u3067\u53d7\u3051\u53d6\u3063\u305f\u6587\u5b57\u5217\u304b\u3089<span>double<\/span>\u3092\u4f5c\u308a\u305f\u3044\u6642\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u3046\u3044\u3046\u6642\u306f<span>Double.parseDouble<\/span>\u3092\u4f7f\u3063\u3066\u6587\u5b57\u5217\u3092<span>double<\/span>\u306b\u5909\u63db\u3057\u307e\u3057\u3087\u3046\u3002<span>double<\/span>\u3068\u89e3\u91c8\u3067\u304d\u306a\u3044\u6587\u5b57\u5217\u306e\u5834\u5408\u306f<span>NumberFormatException<\/span>\u304c<span>throw<\/span>\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">String s = \"12345.56\";\r\n\r\ndouble d1 = Double.parseDouble(s); \/\/ double\u306b\u5909\u63db\u3059\u308b\u6642\u306fparseDouble\u3092\u4f7f\u3046\r\nDouble d2 = Double.valueOf(s); \/\/ Double\u306b\u5909\u63db\u3059\u308b\u6642\u306fvalueOf\u3092\u4f7f\u3046\r\n\r\nSystem.out.println(d1); \/\/ \u2192 12345.56\r\nSystem.out.println(d2); \/\/ \u2192 12345.56<\/pre>\n<p>Double.parseDouble\u3084<span>valueOf<\/span>\u304c\u53d7\u3051\u4ed8\u3051\u308b\u6587\u5b57\u5217\u306f\u3001\u30ea\u30c6\u30e9\u30eb\u306e\u3068\u3053\u308d\u3067\u3082\u304a\u4f1d\u3048\u3057\u305f\u3001<span>10<\/span>\u9032\u6570\u3001<span>10<\/span>\u9032\u6570\u306e\u6307\u6570\u8868\u8a18\u3001<span>16<\/span>\u9032\u6570\u306e\u6307\u6570\u8868\u8a18\u3001\u975e\u6570<span>(NaN)<\/span>\u3001<span>\u00b1<\/span>\u306e\u7121\u9650\u5927<span>(Infinity)<\/span>\u3067\u3059\u3002<span>\u00b10<\/span>\u3082\u304d\u3061\u3093\u3068\u533a\u5225\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">System.out.println(Double.parseDouble(\"-123.456\")); \/\/ 10\u9032\u6570\r\nSystem.out.println(Double.parseDouble(\"123.456e2\")); \/\/ 10\u9032\u6570(\u6307\u6570\u8868\u8a18)\r\nSystem.out.println(Double.parseDouble(\"0x123.456p2\")); \/\/ 16\u9032\u6570(\u6307\u6570\u8868\u8a18)\r\nSystem.out.println(Double.parseDouble(\"NaN\")); \/\/ NaN\u3001\"nan\"\u3067\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308b!!\r\nSystem.out.println(Double.parseDouble(\"Infinity\")); \/\/ \u6b63\u306e\u7121\u9650\r\nSystem.out.println(Double.parseDouble(\"-Infinity\")); \/\/ \u8ca0\u306e\u7121\u9650\r\nSystem.out.println(Double.parseDouble(\"+0\")); \/\/ \u6b63\u306e0\r\nSystem.out.println(Double.parseDouble(\"-0\")); \/\/ \u8ca0\u306e0<\/pre>\n<p>\u306a\u304a\u3001\u6574\u6570\u306e<span>2<\/span>\u9032\u6570\u3001<span>8<\/span>\u9032\u6570\u3001<span>16<\/span>\u9032\u6570\u306f<span>Double.parseDouble<\/span>\u306f\u53d7\u3051\u4ed8\u3051\u307e\u305b\u3093\u3002<span>Long.valueOf<\/span>\u306e\u57fa\u6570\u3092\u6307\u5b9a\u3067\u304d\u308b\u30e1\u30bd\u30c3\u30c9\u3067<span>Long<\/span>\u306b\u5909\u63db\u3057\u305f\u5f8c\u3001<span>doubleValue<\/span>\u3067<span>double<\/span>\u306b\u5909\u63db\u3059\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002\u307e\u305f\u3001<span>long<\/span>\u306f<span>double<\/span>\u306b\u305d\u306e\u307e\u307e\u5909\u63db\u3067\u304d\u307e\u3059\u306e\u3067\u3001<span>Long.parseLong<\/span>\u306e\u623b\u308a\u5024\u306e<span>long<\/span>\u3092<span>double<\/span>\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">System.out.println(Long.valueOf(\"1010\", 2).doubleValue()); \/\/ 2\u9032\u6570\r\nSystem.out.println(Long.valueOf(\"12345670\", 8).doubleValue()); \/\/ 8\u9032\u6570\r\nSystem.out.println(Long.valueOf(\"123456789ABCDEF\", 16).doubleValue()); \/\/ 16\u9032\u6570<\/pre>\n<h3><span id=\"-doubleString\">\uff14-\uff12\uff0edouble\u2192String\u306e\u5909\u63db<\/span><\/h3>\n<h4>\uff14-\uff12-\uff11\uff0eDouble.toString(double)\u30fbString.valueOf(double)\u3067\u5909\u63db\u3059\u308b<\/h4>\n<p>double\u3092String\u306b\u3057\u305f\u3044\u6642\u3082\u983b\u7e41\u306b\u3042\u308a\u307e\u3059\u3002\u7c21\u5358\u306b\u884c\u3046\u306a\u3089\u3001Double.toString(double)\u304b\u3001String.valueOf(double)\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002\u3061\u306a\u307f\u306b\u3001\u3069\u3061\u3089\u3092\u4f7f\u3063\u3066\u3082\u7d50\u679c\u306f\u540c\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d = 123.456;\r\nString s = String.valueOf(d);\r\nSystem.out.println(s); \/\/ \u2192 \"123.456\"<\/pre>\n<h4>\uff14-\uff12-\uff12\uff0eBigDecimal.toPlainString\u3067\u5909\u63db\u3059\u308b<\/h4>\n<p>\u7d76\u5bfe\u5024\u304c\u5927\u304d\u304b\u3063\u305f\u308a\u3001\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6841\u304c\u591a\u3044double\u3092\u3001Double.toString\u3084String.valueOf\u3067\u6587\u5b57\u5217\u306b\u3059\u308b\u3068\u6307\u6570\u8868\u8a18\u306b\u306a\u308a\u307e\u3059\u3002\u666e\u901a\u306e\u66f8\u304d\u65b9\u306e<span>10<\/span>\u9032\u6570\u6587\u5b57\u5217\u306b\u3057\u305f\u3044\u306a\u3089\u3001<span>BigDecimal<\/span>\u306b\u5909\u63db\u3057\u305f\u5f8c\u3001<span>BigDecimal.toPlainString<\/span>\u3092\u4f7f\u3046\u306e\u304c\u7c21\u5358\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d = 123456789012345e-20;\r\n\r\nString s1 = String.valueOf(d);\r\nSystem.out.println(s1); \/\/ \u2192 1.23456789012345E-6\r\n\r\nString s2 = BigDecimal.valueOf(d).toPlainString();\r\nSystem.out.println(s2); \/\/ \u2192 0.00000123456789012345<\/pre>\n<h4>\uff14-\uff12-\uff13\uff0eString.format\u3084<span>DecimalFormat<\/span>\u3067\u66f8\u5f0f\u3092\u4ed8\u3051\u3066\u5909\u63db\u3059\u308b<\/h4>\n<p>double\u3092<span>3<\/span>\u6841\u533a\u5207\u308a\u306a\u3069\u3067\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u305f\u308a\u3001<span>0<\/span>\u57cb\u3081\u3092\u3057\u305f\u308a\u3001\u5c0f\u6570\u90e8\u306e\u56db\u6368\u4e94\u5165\u3092\u3057\u305f\u3044\u5834\u5408\u3082\u3042\u308b\u3067\u3057\u3087\u3046\u3002\u305d\u306e\u5834\u5408\u306f\u3001<span>java.text.DecimalFormat<\/span>\u3084<span>String.format<\/span>\u306a\u3069\u3092\u4f7f\u3044\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u66f8\u5f0f\u306e\u8a73\u7d30\u306f\u3001<span>Javadoc<\/span>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">DecimalFormat df1 = new DecimalFormat(\"#,###.###\"); \/\/ 3\u6841\u533a\u5207\u308a\u3001\u5c0f\u65704\u6841\u76ee\u3067\u56db\u6368\u4e94\u5165\r\nDecimalFormat df2 = new DecimalFormat(\"000,000,000.000\"); \/\/ 3\u6841\u533a\u5207\u308a\u30010\u57cb\u3081\u3042\u308a\u3001\u5c0f\u65704\u6841\u76ee\u3067\u56db\u6368\u4e94\u5165\r\nDecimalFormat df3 = new DecimalFormat(\"#,###.00000\"); \/\/ 3\u6841\u533a\u5207\u308a\u3001\u5c0f\u65705\u6841\u76ee\u307e\u30670\u57cb\u3081\u3057\u3066\u8868\u793a\r\n\r\nString s1 = df1.format(d);\r\nString s2 = df2.format(d);\r\nString s3 = df3.format(d);\r\n\r\nSystem.out.println(s1); \/\/ \u2192 -1,234,567\r\nSystem.out.println(s2); \/\/ \u2192 -001,234,567\r\nSystem.out.println(s3); \/\/ \u2192 -1,234,567.98760<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">double d = -1234567.9876;\r\n\r\nString s1 = String.format(\"%f\", d); \/\/ \u6d6e\u52d5\u5c0f\u6570\u70b9\u3068\u3057\u3066\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u8868\u793a\r\nString s2 = String.format(\"%,.3f\", d); \/\/ \u533a\u5207\u308a\u6587\u5b57\u3042\u308a\u3001\u5c0f\u6570\u90e8\u306f4\u6841\u76ee\u3067\u56db\u6368\u4e94\u5165\r\nString s3 = String.format(\"%,018.3f\", d); \/\/ \u7b26\u53f7\u3084\u533a\u5207\u308a\u6587\u5b57\u3082\u542b\u3081\u3066\u5168\u4f53\u306718\u6587\u5b57\u30010\u57cb\u3081\u3042\u308a\u3001\u5c0f\u6570\u90e8\u306f4\u6841\u76ee\u3067\u56db\u6368\u4e94\u5165\r\nString s4 = String.format(\"%e\", d); \/\/ \u6307\u6570\u8868\u8a18(E\u3060\u3068\u5927\u6587\u5b57)\r\n\r\nSystem.out.println(s1); \/\/ \u2192 -1234567.987600\r\nSystem.out.println(s2); \/\/ \u2192 -1,234,567.988\r\nSystem.out.println(s3); \/\/ \u2192 -00001,234,567.988\r\nSystem.out.println(s4); \/\/ \u2192 -1.234568e+06<\/pre>\n<blockquote>\n<p>\u3010\u53c2\u8003\u3011java.text.DecimalFormat<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/text\/DecimalFormat.html\">https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/text\/DecimalFormat.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u3010\u53c2\u8003\u3011java.lang.String.format<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/lang\/String.html#format(java.lang.String,java.lang.Object...)\">https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/lang\/String.html#format(java.lang.String,java.lang.Object&#8230;)<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u3010\u53c2\u8003\u3011java.util.Formatter<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/util\/Formatter.html\">https:\/\/docs.oracle.com\/javase\/jp\/11\/docs\/api\/java.base\/java\/util\/Formatter.html<\/a><\/p>\n<\/blockquote>\n<h4>\uff14-\uff12-\uff14\uff0eDouble.doubleToRawLongBits\u30fbdoubleToLongBits\u3067\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u306b\u5909\u63db\u3059\u308b<\/h4>\n<p>double\u304c\u6301\u3064\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u3092\u305d\u306e\u307e\u307e\u6587\u5b57\u5217\u306b\u3057\u305f\u3044\u5834\u5408\u306f\u3001Double.doubleToRawLongBits\u307e\u305f\u306fdoubleToLongBits\u3067long\u306b\u5909\u63db\u3057\u305f\u5f8c\u3001Long.toBinaryString\u306701\u306e\u6587\u5b57\u5217\u306b\u3057\u307e\u3059\u3002\u3055\u3089\u306b<span>String.format<\/span>\u3068<span>replace<\/span>\u3092\u7d4c\u7531\u3057\u3066\u3044\u308b\u306e\u306f\u3001\u7b26\u53f7\u304c\u6b63\u306a\u3089\u5148\u982d\u3078<span>0<\/span>\u3092\u4ed8\u3051\u305f\u3044\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d = 123.456;\r\nString s = String.format(\"%64s\", Long.toBinaryString(Double.doubleToRawLongBits(d))).replace(\" \", \"0\");\r\nSystem.out.println(s); \/\/ \u2192 0100000001011110110111010010111100011010100111111011111001110111<\/pre>\n<p>\u3053\u306e\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u306f<span>IEEE 754<\/span>\u306e\u500d\u7cbe\u5ea6\u6d6e\u52d5\u5c0f\u6570\u70b9\u306e\u4ed5\u69d8\u305d\u306e\u307e\u307e\u306a\u306e\u3067\u3001<span>IEEE 754<\/span>\u306e\u52c9\u5f37\u3092\u3059\u308b\u306e\u306b\u3082\u4f7f\u3048\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001Double.doubleToRawLongBits\u30fbdoubleToLongBits\u306e\u9055\u3044\u306f\u975e\u6570(NaN)\u306e\u6271\u3044\u3067\u3001doubleToRawLongBits\u306f\u30d3\u30c3\u30c8\u30d1\u30bf\u30fc\u30f3\u305d\u306e\u307e\u307e\u3001doubleToLongBits\u306f\u6b63\u898f\u5316\u3055\u308c\u305f\u4e00\u3064\u306eNaN\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n<h2><span id=\"doubleDouble\">\uff15\uff0edouble\u3068<span>Double<\/span><\/span><\/h2>\n<p>Java\u3067\u306f<span>64<\/span>\u30d3\u30c3\u30c8\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u3092\u8868\u73fe\u3059\u308b\u305f\u3081\u306b\u3001<span>double<\/span>\u3068<span>Double<\/span>\u306e\u4e8c\u3064\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<span>Java<\/span>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u521d\u5fc3\u8005\u306f\u3001\u306a\u305c\u8868\u3057\u65b9\u304c\u4e8c\u3064\u3042\u308b\u306e\u304b\u6df7\u4e71\u3059\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u305d\u306e\u7406\u7531\u3068\u3001<span>double<\/span>\u3068<span>Double<\/span>\u306e\u4f7f\u3044\u5206\u3051\u306e\u65b9\u91dd\u306a\u3069\u3092\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"i\">\uff15-\uff11\uff0e\u4e8c\u7a2e\u985e\u306e\u8868\u73fe\u65b9\u6cd5\u306f\u6027\u80fd\u78ba\u4fdd\u306e\u305f\u3081<\/span><\/h3>\n<p>Java\u3067\u306f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e<span>double<\/span>\u3068\u3001\u30af\u30e9\u30b9\u306e<span>Double<\/span>\u306f\u5225\u7269\u3067\u3059\u3002<span>C#<\/span>\u306a\u3069\u3067\u306f\u3053\u3046\u3044\u3046\u533a\u5225\u304c\u306a\u3044\u306e\u306b\u3001\u306a\u305c<span>Java<\/span>\u3067\u306f\u3042\u308b\u306e\u304b\u3002\u3053\u308c\u306f\u3001<span>Java<\/span>\u304c\u751f\u307e\u308c\u305f\u5f53\u6642\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u901f\u5ea6\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u3067\u3057\u305f\u3002<\/p>\n<p>Java\u306f<span>1995<\/span>\u5e74\u306b\u767b\u5834\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3059\u3002\u5f53\u6642\u306e<span>CPU<\/span>\u306e\u30af\u30ed\u30c3\u30af\u5468\u6ce2\u6570\u306f\u4eca\u3068\u306f\u6841\u304c\u9055\u3044\u3001\u4e00\u822c\u5411\u3051\u306e<span>CPU<\/span>\u3067\u3088\u3046\u3084\u304f<span>100MHz<\/span>\u3092\u8d85\u3048\u305f\u304f\u3089\u3044\u3002\u30e1\u30e2\u30ea\u306e\u91cf\u3082\u5168\u4f53\u3067\u6570<span>MB<\/span>\uff5e\u6570<span>10MB<\/span>\u3068\u975e\u5e38\u306b\u4e4f\u3057\u304b\u3063\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>double\u306f<span>64<\/span>\u30d3\u30c3\u30c8\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u305d\u306e\u3082\u306e\u3067\u3059\u3057\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306b\u306f\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u3092\u5c02\u7528\u306b\u8a08\u7b97\u3059\u308b\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u304c\u642d\u8f09\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u697d\u306b\u901f\u304f\u6271\u3048\u307e\u3059\u3002\u3057\u304b\u3057\u3001<span>double<\/span>\u3092\u30af\u30e9\u30b9\u3068\u3059\u308b\u3068\u3001\u4e00\u3064\u306e<span>double<\/span>\u306e\u6570\u5b57\u306b<span>64<\/span>\u30d3\u30c3\u30c8\u4ee5\u4e0a\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3044\u307e\u3059\u3057\u3001\u8a08\u7b97\u4e0a\u3067\u3082\u4f59\u5206\u306a\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"-Doublenull\">\uff15-\uff12\uff0e\u30af\u30e9\u30b9\u306e<span>Double<\/span>\u306a\u3089<span>null<\/span>\u3092\u8868\u73fe\u3067\u304d\u308b<\/span><\/h3>\n<p>Java\u3067<span>Double<\/span>\u3092\u4f7f\u3046\u306e\u306f\u3001<span>Double<\/span>\u304c\u6301\u3064\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u305f\u3044\u6642\u3068\u3001\u5024\u304c\u306a\u3044\u5834\u5408<span>\u2026<\/span>\u3059\u306a\u308f\u3061<span>null<\/span>\u3092\u8868\u73fe\u3057\u305f\u3044\u6642\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001<span>SQL<\/span>\u3067\u306f\u5024\u306e\u6709\u308a\u7121\u3057\u3092<span>NULL<\/span>\u304b\u3069\u3046\u304b\u3067\u8868\u73fe\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u308c\u3092<span>Java<\/span>\u306e<span>double<\/span>\u3067\u306f\u4e0a\u624b\u306b\u8868\u73fe\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3067\u3059\u304b\u3089\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3067\u306f<span>0<\/span>\u3084<span>-1<\/span>\u306a\u3069\u306e\u5024\u306b\u7279\u5225\u306a\u610f\u5473\u3092\u6301\u305f\u305b\u305f\u308a\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u78ba\u5b9f\u3055\u306b\u306f\u6b20\u3051\u307e\u3059\u3002\u305d\u3046\u3044\u3046\u5024\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5fd8\u308c\u308b\u306a\u3069\u306e\u30df\u30b9\u3082\u3057\u304c\u3061\u3067\u3059\u3002<\/p>\n<p>\u305d\u3046\u3044\u3046\u6642\u306b\u53c2\u7167\u578b\u3067\u3042\u308b<span>Double<\/span>\u3092\u4f7f\u3048\u3070\u3001\u5024\u304c\u306a\u3044\u3053\u3068\u3092<span>null<\/span>\u3068\u3057\u3066\u8868\u73fe\u3067\u304d\u308b\u306e\u3067\u3059\u3002<span>Double<\/span>\u3092\u3069\u3046\u3044\u3046\u6642\u306b\u4f7f\u3046\u304b\u5206\u304b\u3089\u306a\u3044\u65b9\u306f\u3001\u305d\u306e\u5909\u6570\u3067<span>null<\/span>\u3092\u8868\u73fe\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u3092\u4e00\u3064\u306e\u6307\u91dd\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3><span id=\"-doubleDouble\">\uff15-\uff13\uff0e\u30aa\u30fc\u30c8\u30dc\u30af\u30b7\u30f3\u30b0\u3067<span>double<\/span>\u3068<span>Double<\/span>\u3092\u81ea\u52d5\u5909\u63db\u3059\u308b<\/span><\/h3>\n<p>Java 1.5\u3067\u30aa\u30fc\u30c8\u30dc\u30af\u30b7\u30f3\u30b0<span>(auto boxing)<\/span>\u3068\u3044\u3046\u4ed5\u7d44\u307f\u304c\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002\u30aa\u30fc\u30c8\u30dc\u30af\u30b7\u30f3\u30b0\u3067\u3001<span>double<\/span>\u3068<span>Double<\/span>\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3067\u307b\u307c\u540c\u3058\u3082\u306e\u3068\u3057\u3066\u6271\u3048\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3067<span>double<\/span>\u3092\u4f7f\u3046\u6240\u3067\u306f<span>Double<\/span>\u3092\u4f7f\u3048\u307e\u3059\u3057\u3001<span>Double<\/span>\u3092\u4f7f\u3046\u6240\u3067\u306f<span>double<\/span>\u304c\u4f7f\u3048\u307e\u3059\u3002\u672c\u5f53\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u306f\u76f8\u5909\u308f\u3089\u305a<span>double<\/span>\u3068<span>Double<\/span>\u306f\u5225\u7269\u306a\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u9055\u3044\u3092<span>Java<\/span>\u304c\u88cf\u3067\u81ea\u52d5\u7684\u306b\u5909\u63db\u3092\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Double doubleObj = Double.valueOf(\"12345\"); \/\/ Double\r\ndouble doublePri = 65535; \/\/ double\r\n\r\ndoublePri = doubleObj; \/\/ \u2192 12345\u3001double\u306bDouble\u3092\u4ee3\u5165\u3067\u304d\u308b\r\ndoublePri = new Double(\"65535\"); \/\/ \u2192 65535\u3001\u540c\u4e0a\r\ndoubleObj = 12345; \/\/ \u2192 12345\u3001Double\u306bdouble\u3092\u4ee3\u5165\u3067\u304d\u308b<\/pre>\n<p>\u3053\u308c\u3067<span>Java<\/span>\u306e\u9762\u5012\u306a\u90e8\u5206\u304c\u3042\u308b\u7a0b\u5ea6\u89e3\u6d88\u3055\u308c\u307e\u3057\u305f\u3002\u3067\u3059\u304c\u3001\u524d\u8ff0\u306e\u3068\u304a\u308a<span>Double<\/span>\u306f<span>null<\/span>\u3092\u8868\u305b\u307e\u3059\u304c\u3001<span>double<\/span>\u306f\u5fc5\u305a\u4f55\u304b\u306e\u6574\u6570\u306a\u306e\u3067\u3001<span>null<\/span>\u306b\u76f8\u5f53\u3059\u308b\u3082\u306e\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3067\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4e88\u671f\u305b\u306c\u3068\u3053\u308d\u3067<span>NullPodoubleerException<\/span>\u304c\u767a\u751f\u3057\u305f\u308a\u3057\u307e\u3059\u3002\u3053\u308c\u306f<span>2019<\/span>\u5e74\u306e<span>Java 11<\/span>\u306e\u6642\u70b9\u3067\u3082\u5909\u308f\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u6ce8\u610f\u3059\u308b\u304b\u3001<span>Optional<\/span>\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">class IntTest {\r\n\tstatic Double returnDouble() {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tdouble i = returnDouble(); \/\/ \u2192 null\u3092double\u306b\u5909\u63db\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u5b9f\u884c\u3059\u308b\u3068NullPointerException\u304c\u767a\u751f\u3059\u308b!!\r\n\t}\r\n}<\/pre>\n<h2><span id=\"double-3\">\uff16\uff0e\u3010\u767a\u5c55\u3011<span>double<\/span>\u3068\u8aa4\u5dee<\/span><\/h2>\n<p>double\u306e\u3088\u3046\u306a\u6d6e\u52d5\u5c0f\u6570\u70b9\u3092\u4f7f\u3063\u305f\u8a08\u7b97\u3067\u306f\u3001\u3044\u308d\u3044\u308d\u306a\u8aa4\u5dee\u306b\u6c17\u3092\u4ed8\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u8aa4\u5dee\u304c\u51fa\u308b\u7406\u7531\u306f\u3001<span>double<\/span>\u304c<span>2<\/span>\u9032\u6570\u3067\u3042\u308b\u3053\u3068\u3068\u3001\u6570\u5b57\u306b\u4f7f\u3048\u308b\u30d3\u30c3\u30c8\u6570\u3001\u7279\u306b\u4eee\u6570\u304c\u6709\u9650\u3067\u3042\u308b\u3053\u3068\u304c\u4e3b\u306a\u539f\u56e0\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u306f\u5177\u4f53\u4f8b\u3092\u6319\u3052\u3066\u8aac\u660e\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u5185\u5bb9\u3092\u6b63\u78ba\u306b\u7406\u89e3\u3059\u308b\u306b\u306f\u3001\u6570\u5024\u8a08\u7b97\u3092\u884c\u3046\u6642\u306e\u300c\u6709\u52b9\u6570\u5b57<span>(<\/span>\u6709\u52b9\u6841\u6570<span>)<\/span>\u300d\u3068\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u306e\u300c\u6b63\u898f\u5316\u300d\u3068\u3044\u3046\u8003\u3048\u65b9\u306e\u77e5\u8b58\u304c\u524d\u63d0\u3068\u306a\u308a\u307e\u3059\u3002\u6709\u52b9\u6570\u5b57\u3084\u6b63\u898f\u5316\u306e\u8003\u3048\u65b9\u306f\u3001\u4ee5\u4e0b\u306a\u3069\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<blockquote>\n<p>\u3010\u53c2\u8003\u3011\u6709\u52b9\u6570\u5b57(Wikipedia)<\/p>\n<p><a href=\"https:\/\/ja.wikipedia.org\/wiki\/\u6709\u52b9\u6570\u5b57\">https:\/\/ja.wikipedia.org\/wiki\/\u6709\u52b9\u6570\u5b57<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u3010\u53c2\u8003\u3011\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570(Wikipedia)<\/p>\n<p><a href=\"https:\/\/ja.wikipedia.org\/wiki\/\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\">https:\/\/ja.wikipedia.org\/wiki\/\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570<\/a><\/p>\n<\/blockquote>\n<h3><span id=\"i-2\">\uff16-\uff11\uff0e\u4e38\u3081\u8aa4\u5dee<span>\/<\/span>\u6253\u5207\u308a\u8aa4\u5dee<\/span><\/h3>\n<p>\u672c\u6765\u8868\u3057\u305f\u3044\u6570\u5b57\u3068\u5b9f\u969b\u306e\u6570\u5b57\u306b\u3001\u6570\u5b57\u306b\u4f7f\u3048\u308b\u6841\u6570\u306e\u305b\u3044\u3067\u5dee\u304c\u51fa\u308b\u3053\u3068\u3092\u300c\u4e38\u3081\u8aa4\u5dee\u300d\u3084\u300c\u6253\u5207\u308a\u8aa4\u5dee\u300d\u3068\u547c\u3073\u307e\u3059\u3002\u5148\u8ff0\u306e\u3068\u304a\u308a\u3001<span>double<\/span>\u3067\u306f<span>1\/10=0.1<\/span>\u3092\u6b63\u78ba\u306b\u8868\u305b\u307e\u305b\u3093\u3002<span>0.1<\/span>\u306f<span>2<\/span>\u9032\u6570\u3060\u3068\u5faa\u74b0\u5c0f\u6570\u3067\u3059\u304c\u3001<span>double<\/span>\u306f\u6709\u9650\u306a\u306e\u3067\u3001\u3069\u3053\u304b\u3067\u56db\u6368\u4e94\u5165\u306a\u3069\u3067\u4e38\u3081\u308b\u304b\u3001\u6253\u3061\u5207\u3089\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>1\/10(10\u9032\u6570<span>)<br \/>\n<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u2193<br \/>\n0.1(10\u9032\u6570<span>)<\/span><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u2193<\/p>\n<p>0.000(1100)(2\u9032\u6570\u3001\u6700\u5f8c\u306e<span>1100<\/span>\u304c\u7121\u9650\u306b\u7d9a\u304f<span>)<\/span><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u2193<\/p>\n<p>double\u3060\u3068\u9014\u4e2d\u3067\u6253\u3061\u5207\u3089\u308c<span>0.1000000000000000055511151231257827021181583404541015625<\/span>\u306b\u306a\u308b<\/p>\n<\/blockquote>\n<p>\u6570\u5b57\u306f\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u4e0a\u3067\u306f<span>2<\/span>\u9032\u6570\u306b\u306a\u308a\u307e\u3059\u3002<span>2<\/span>\u306e\u500d\u6570\u3068\u305d\u306e\u5408\u8a08\u3067\u8868\u3059<span>2<\/span>\u9032\u6570\u3067\u306f\u3001<span>10<\/span>\u9032\u6570\u3067\u304d\u3063\u3061\u308a\u8868\u305b\u308b\u5c0f\u6570\u3067\u3082\u305d\u306e\u307e\u307e\u8868\u305b\u306a\u3044\u3082\u306e\u304c\u307b\u3068\u3093\u3069\u3067\u3059\u3002\u6b63\u78ba\u306a\u8a08\u7b97\u304c\u5fc5\u8981\u306a\u3089\u3001\u4e8c\u9032\u5316\u5341\u9032\u6570<span>(BCD<\/span>\u3001<span>Binary-coded decimal)<\/span>\u306e\u30af\u30e9\u30b9\u3084\u3001\u6709\u7406\u6570\u306e\u307e\u307e\u8a08\u7b97\u3067\u304d\u308b\u30af\u30e9\u30b9\u306a\u3069\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u306a\u304a\u3001\u4e38\u3081\u8aa4\u5dee<span>\/<\/span>\u6253\u5207\u308a\u8aa4\u5dee\u306f<span>2<\/span>\u9032\u6570\u3060\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4f8b\u3048\u3070\u3001<span>1\/3<\/span>\u306f<span>10<\/span>\u9032\u6570\u3067<span>0.333\u2026<\/span>\u3067\u3059\u304c\u3001\u6709\u9650\u306e\u6841\u3067\u8868\u3059\u306a\u3089\u7121\u9650\u306b\u7d9a\u304f<span>3<\/span>\u3092\u3069\u3053\u304b\u3067\u7d42\u308f\u3089\u305b\u307e\u3059\u3002\u305d\u3057\u3066\u3001<span>1\/3<\/span>\u3068\u3069\u3053\u304b\u306e\u6841\u3067\u7d42\u308f\u3063\u305f<span>0.333\u2026<\/span>\u306f\u9055\u3046\u3082\u306e\u3067\u3059\u3002\u3053\u308c\u3068\u7406\u5c48\u306f\u540c\u3058\u3067\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306f<span>2<\/span>\u9032\u6570\u304c\u30d9\u30fc\u30b9\u306a\u3060\u3051\u3067\u3059\u3002<\/p>\n<h3><span id=\"i-3\">\uff16-\uff12\uff0e\u6841\u843d\u3061<\/span><\/h3>\n<p>\u8fd1\u3044\u6570\u5b57\u540c\u58eb\u3092\u5f15\u304d\u7b97\u3057\u305f\u7d50\u679c\u3001\u6570\u5b57\u306e\u6709\u52b9\u6570\u5b57<span>(<\/span>\u6709\u52b9\u6841\u6570<span>)<\/span>\u304c\u5c11\u306a\u304f\u306a\u308b\u3053\u3068\u3092\u6841\u843d\u3061\u3068\u8a00\u3044\u307e\u3059\u3002\u8aa4\u5dee\u3092\u8003\u616e\u3057\u305f\u8a08\u7b97\u3067\u306f\u3001\u3053\u306e\u3088\u3046\u306a\u8a08\u7b97\u304c\u9014\u4e2d\u3067\u3055\u308c\u306a\u3044\u3088\u3046\u306b\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f<span>2<\/span>\u3064\u306e\u6570\u5b57\u4e21\u65b9\u3067\u6709\u52b9\u6570\u5b57\u306f<span>15<\/span>\u6841\u3067\u3001\u5c0f\u6570\u90e8<span>15<\/span>\u6841\u76ee\u306b<span>1<\/span>\u3060\u3051\u5dee\u304c\u3042\u308a\u307e\u3059\u3002<span>d1<\/span>\u3068<span>d2<\/span>\u3092\u5f15\u304d\u7b97\u3059\u308b\u3068<span>10<\/span>\u9032\u6570\u3067\u306f<span>0.000000000000001<\/span>\u3067\u3001\u6b63\u898f\u5316\u3059\u308b\u3068<span>1e-15<\/span>\u3068\u306a\u308a\u3001\u6709\u52b9\u6570\u5b57\u306f<span>15<\/span>\u6841\u304b\u3089<span>1<\/span>\u6841\u3078\u4e00\u6c17\u306b\u6e1b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 0.123456789012345; \/\/ \u2192 1.23456789012345e-1\r\ndouble d2 = 0.123456789012344; \/\/ \u2192 1.23456789012344e-1\r\ndouble d3 = d1 - d2;\r\nSystem.out.println(d3); \/\/ \u2192 9.992007221626409E-16(0.0000000000000009992007221626409)<\/pre>\n<p>\u5b9f\u969b\u306e<span>double<\/span>\u3067\u306e\u8a08\u7b97\u7d50\u679c\u306f\u3001<span>2<\/span>\u9032\u6570\u3078\u306e\u5909\u63db\u8aa4\u5dee\u306e\u305f\u3081<span>1e-15<\/span>\u3061\u3087\u3046\u3069\u306b\u306f\u306a\u3089\u305a\u3001\u3054\u304f\u308f\u305a\u304b\u306b\u5c0f\u3055\u306a\u6570\u5b57\u3067\u3059\u3002\u305d\u3057\u3066\u3001\u8a08\u7b97\u7d50\u679c\u306e\u6709\u52b9\u6570\u5b57\u306f<span>16<\/span>\u6841\u3042\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u8a08\u7b97\u306b\u4f7f\u3063\u305f<span>double<\/span>\u306e\u6709\u52b9\u6570\u5b57\u3088\u308a\u5c0f\u3055\u3044\u6570\u5b57\u306a\u306e\u3067\u3001\u8a08\u7b97\u4e0a\u3067\u610f\u5473\u304c\u3042\u308b\u6570\u5b57\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>\uff16-\uff12-\uff11\uff0e\u6841\u843d\u3061\u306f\u8aa4\u5dee\u3092\u8003\u616e\u3057\u305f\u8a08\u7b97\u3067\u306f\u81f4\u547d\u7684<\/h4>\n<p>\u6841\u843d\u3061\u304c\u554f\u984c\u306a\u306e\u306f\u3001\u4e0d\u78ba\u304b\u306a\u6570\u5b57\u304c\u8a08\u7b97\u9014\u4e2d\u306b\u51fa\u73fe\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u4ee5\u5f8c\u306e\u8a08\u7b97\u7d50\u679c\u306b\u5927\u304d\u306a\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u9014\u4e2d\u306e\u8a08\u7b97\u7d50\u679c\u3067<span>1.000e-3<\/span>\u3068\u3044\u3046\u6570\u5b57\u304c\u51fa\u305f\u3068\u3057\u3066\u3001\u4eee\u6570\u306e<span>0<\/span>\u306e\u90e8\u5206\u304c\u672c\u5f53\u306b<span>0<\/span>\u304b\u3001\u6841\u843d\u3061\u306b\u3088\u308b\u6b63\u898f\u5316\u3067\u57cb\u3081\u3089\u308c\u305f<span>0<\/span>\u304b\u306f\u308f\u304b\u308a\u307e\u305b\u3093\u3002\u3082\u3057\u3001\u8a08\u7b97\u4e0a\u3067\u3053\u306e\u6570\u5b57\u3092\u4f7f\u3046\u306a\u3089\u3001\u3053\u306e\u4e0d\u78ba\u304b\u306a<span>0<\/span>\u304c\u305a\u3063\u3068\u4ed8\u304d\u307e\u3068\u3046\u306e\u3067\u3059\u3002<\/p>\n<p>double\u3067\u8a08\u7b97\u3092\u3059\u308c\u3070\u4f55\u3089\u304b\u306e\u6570\u5b57\u306f\u51fa\u3066\u6765\u307e\u3059\u3002\u3067\u3082\u3001\u305d\u306e\u6570\u5b57\u306b\u3069\u308c\u3060\u3051\u610f\u5473\u304c\u3042\u308b\u304b\u306e\u89b3\u70b9\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u5f37\u304f\u610f\u8b58\u3059\u3079\u304d\u3053\u3068\u3067\u3059\u3002\u305d\u3057\u3066\u3001\u6841\u843d\u3061\u3082<span>2<\/span>\u9032\u6570\u7279\u6709\u306e\u4e8b\u8c61\u3067\u306f\u306a\u3044\u3053\u3068\u306f\u77e5\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3><span id=\"i-4\">\uff16-\uff13\uff0e\u60c5\u5831\u843d\u3061<\/span><\/h3>\n<p>\u60c5\u5831\u843d\u3061\u3068\u306f\u3001\u7d76\u5bfe\u5024\u304c\u5927\u304d\u304f\u9055\u3046\u6570\u5b57\u540c\u58eb\u3067\u8a08\u7b97\u3092\u3059\u308b\u3068\u3001\u7d76\u5bfe\u5024\u304c\u5c0f\u3055\u306a\u65b9\u306e\u6570\u5b57\u304c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u73fe\u8c61\u3067\u3059\u3002\u6841\u843d\u3061\u3088\u308a\u306f\u8a08\u7b97\u8aa4\u5dee\u3078\u306e\u5f71\u97ff\u306f\u5c11\u306a\u3044\u3067\u3059\u304c\u3001\u3067\u304d\u308b\u3060\u3051\u907f\u3051\u308b\u3079\u304d\u3082\u306e\u306a\u306e\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u8db3\u3057\u7b97\u3067\u306f\u3001<span>d1<\/span>\u3068<span>d2<\/span>\u3068\u3082\u306b<span>15<\/span>\u6841\u5206\u306e\u6709\u52b9\u6841\u6570\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u4e8c\u3064\u306e\u6570\u5b57\u3092\u8db3\u3057\u5408\u308f\u305b\u3066\u3082\u3001\u7d19\u3067\u8a08\u7b97\u3057\u305f\u3068\u304a\u308a\u306e<span>123456789012345.123456789012345<\/span>\u3068\u306f\u306a\u3089\u305a\u3001<span>123456789012345.12<\/span>\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u3068\u3044\u3046\u3053\u3068\u306f\u3001<span>d2<\/span>\u306e\u65b9\u306e\u5c0f\u6570\u70b9\u7b2c<span>3<\/span>\u4f4d\u4ee5\u4e0b\u306e\u6570\u5b57\u304c\u306a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3088\u306d\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 123456789012345.0; \/\/ \u2192 1.23456789012345e15\r\ndouble d2 = 0.123456789012345; \/\/ \u2192 1.23456789012345e-1\r\ndouble d3 = d1 + d2;\r\n\r\nSystem.out.println(d1); \/\/ \u2192 1.23456789012345E14\r\nSystem.out.println(d2); \/\/ \u2192 0.123456789012345\r\nSystem.out.println(d3); \/\/ \u2192 1.2345678901234512E14(123456789012345.12)<\/pre>\n<p>\u3053\u3046\u306a\u308b\u7406\u7531\u306f\u3001\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u3067\u306e\u4eee\u6570\u306b\u306f\u6841\u6570\u306e\u5236\u9650\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<span>double<\/span>\u306e\u4eee\u6570\u306b\u306f\u3001\u3053\u306e\u4f8b\u3067\u306e\u7d19\u3067\u8a08\u7b97\u3057\u305f\u5834\u5408\u306e<span>30<\/span>\u6841\u306b\u304a\u3088\u3076\u6709\u52b9\u6570\u5b57\u3092\u8868\u305b\u308b\u6841\u6570\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u3067\u3059\u304b\u3089\u3001<span>1.2345678901234512<\/span>\u307e\u3067\u304c\u3001\u3053\u306e\u8a08\u7b97\u7d50\u679c\u3092<span>double<\/span>\u306e\u4eee\u6570\u3067\u8868\u73fe\u3067\u304d\u308b\u9650\u754c\u3060\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<h4>\uff16-\uff13-\uff11\uff0e\u60c5\u5831\u843d\u3061\u306b\u306f\u8a08\u7b97\u9806\u5e8f\u304c\u5f71\u97ff\u3059\u308b<\/h4>\n<p>\u60c5\u5831\u843d\u3061\u304c\u554f\u984c\u306b\u306a\u308b\u306e\u306f\u3001\u5927\u304d\u306a\u6570\u5b57\u3068\u5c0f\u3055\u306a\u6570\u5b57\u3092\u9023\u7d9a\u3057\u3066\u8a08\u7b97\u3059\u308b\u6642\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u3001\u524d\u8005\u3067\u306f<span>0.001\u00d710=0.01<\/span>\u304c\u8a08\u7b97\u7d50\u679c\u306b<span>(<\/span>\u8aa4\u5dee\u306f\u51fa\u3064\u3064\u3082<span>)<\/span>\u53cd\u6620\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u5f8c\u8005\u3067\u306f\u672a\u53cd\u6620\u3067\u3059\u3002\u57fa\u672c\u7684\u306b\u306f\u3001\u524d\u8005\u306e\u3088\u3046\u306b\u5c0f\u3055\u306a\u5024\u3092\u307e\u3068\u3081\u3066\u5148\u306b\u8a08\u7b97\u3057\u3066\u3001\u305d\u306e\u5f8c\u306b\u5927\u304d\u306a\u5024\u3068\u8a08\u7b97\u3057\u3066\u56de\u907f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 123456789000000.0;\r\ndouble d2 = 0.001;\r\ndouble d3 = 0;\r\n\r\nfor (int i = 0; i &lt; 10; i++) {\r\n\td3 += d2; \/\/ d2\u309210\u56de\u8db3\u3057\u5408\u308f\u305b\u305f\u6570\u5b57\u3092\u5148\u306b\u4f5c\u3063\u3066\u3001\r\n}\r\n\r\ndouble d4 = d1 + d3; \/\/ \u305d\u306e\u7d50\u679c\u3092\u8db3\u3057\u5408\u308f\u305b\u308b\r\n\r\nSystem.out.println(d3); \/\/ \u2192 0.010000000000000002\r\nSystem.out.println(d4); \/\/ \u2192 1.2345678901234502E14(123456789012345.02)<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">double d1 = 123456789000000.0;\r\ndouble d2 = 0.001;\r\ndouble d3 = d1;\r\n\r\nfor (int i = 0; i &lt; 10; i++) {\r\n\td3 += d2; \/\/ d2\u3092\u76f4\u63a5\u8db3\u3057\u5408\u308f\u305b\u308b\r\n}\r\n\r\nSystem.out.println(d3); \/\/ \u2192 1.23456789012345E14(123456789012345)<\/pre>\n<h3><span id=\"-BigDecimal\">\uff16-\uff14\uff0eBigDecimal\u306b\u3088\u308b\u6b63\u78ba\u306a\u8a08\u7b97\u306e\u4f8b<\/span><\/h3>\n<p>\u6b63\u78ba\u306a\u6570\u5b57\u306e\u8868\u73fe\u3084\u8a08\u7b97\u3092\u884c\u3046\u306a\u3089\u3001<span>Java<\/span>\u3067\u306f<span>java.math.BigDecimal<\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002\u3053\u3053\u307e\u3067\u306b\u4f8b\u3068\u3057\u3066\u6319\u3052\u3066\u304d\u305f\u8aa4\u5dee\u304c\u51fa\u308b\u8a08\u7b97\u3082\u3001\u6b63\u78ba\u306b\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3001\u8a08\u7b97\u901f\u5ea6\u306f<span>double\/float<\/span>\u3092\u4f7f\u3046\u5834\u5408\u3088\u308a\u3082\u3069\u3046\u3057\u3066\u3082\u9045\u304f\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u4f7f\u3044\u5206\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ BigDecimal\u306a\u30890.1\u309210\u56de\u8db3\u3059\u30681\u306b\u306a\u308b!!\r\nBigDecimal diff = new BigDecimal(\"0.1\");\r\nBigDecimal sum = BigDecimal.ZERO;\r\n\r\nfor (int i = 0; i &lt; 10; i++) {\r\n\tsum = sum.add(diff);\r\n}\r\n\r\nSystem.out.println(sum); \/\/ \u2192 1.0\u30010.1\u309210\u56de\u8db3\u3057\u305f\u306e\u3068\u540c\u3058\u7d50\u679c\u306b\u306a\u308b\r\n\r\n\/\/ BigDecimal\u3092\u4f7f\u3063\u305f\u6841\u843d\u3061\u3068\u60c5\u5831\u843d\u3061\u306e\u78ba\u8a8d\r\nBigDecimal bd1 = new BigDecimal(\"123456789012345\");\r\nBigDecimal bd2 = new BigDecimal(\"0.123456789012345\");\r\nBigDecimal bd3 = new BigDecimal(\"0.123456789012344\");\r\n\r\n\/\/ BigDecimal\u3067\u3082\u6841\u843d\u3061\u306f\u3059\u308b\u304c\u3001\u6570\u5b57\u306f\u6b63\u78ba\r\nBigDecimal bd4 = bd2.subtract(bd3); \/\/ 0.123456789012345 - 0.123456789012344\r\nSystem.out.println(bd4.toPlainString()); \/\/ \u2192 \u6b63\u78ba\u306b0.000000000000001\r\nSystem.out.println(bd4.precision()); \/\/ \u2192 \u7cbe\u5ea6\u306f1\u306a\u306e\u3067\u3001\u6841\u843d\u3061\u306f\u3057\u3066\u3044\u308b\r\n\r\n\/\/ double\u3067\u306f\u60c5\u5831\u843d\u3061\u3057\u3066\u3044\u305f\u8a08\u7b97\u3067\u3082\u5927\u4e08\u592b\r\nBigDecimal bd5 = bd1.add(bd2); \/\/ 123456789012345 + 0.123456789012345\r\nSystem.out.println(bd5); \/\/ \u2192 123456789012345.123456789012345\u3001\u60c5\u5831\u843d\u3061\u3057\u3066\u3044\u306a\u3044!!<\/pre>\n<p>\u6b63\u78ba\u306a\u8a08\u7b97\u306b\u5fc5\u8981\u306a\u30b9\u30b1\u30fc\u30eb<span>(<\/span>\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6841\u6570<span>)<\/span>\u306f\u81ea\u52d5\u7684\u306b\u5224\u65ad\u3055\u308c\u307e\u3059\u304c\u3001\u4efb\u610f\u306e\u30b9\u30b1\u30fc\u30eb\u3084\u4e38\u3081\u65b9\u6cd5\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u7279\u306b\u3001\u5272\u308a\u7b97\u3092\u3059\u308b\u6642\u306f\u3069\u3053\u307e\u3067\u306e\u30b9\u30b1\u30fc\u30eb\u304c\u5fc5\u8981\u304b\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001\u5272\u308a\u5207\u308b\u3053\u3068\u304c\u51fa\u6765\u306a\u3044\u5834\u5408\u306a\u3069\u306b\u8a08\u7b97\u3092\u7d42\u3048\u3089\u308c\u305a\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">BigDecimal bd1 = new BigDecimal(\"1\");\r\nBigDecimal bd2 = new BigDecimal(\"3\");\r\n\r\n\/\/ BigDecimal bd3 = bd1.divide(bd2); \/\/ \u2192 1\/3\u306f\u5272\u308a\u5207\u308c\u306a\u3044\u306e\u3067\u3001java.lang.ArithmeticException\u304c\u767a\u751f\u3059\u308b\r\nBigDecimal bd4 = bd1.divide(bd2, 10, RoundingMode.HALF_EVEN); \/\/ \u5c0f\u6570\u70b910\u6841\u307e\u3067\u3001\u4e38\u3081\u306f\u56db\u6368\u4e94\u5165\r\nBigDecimal bd5 = bd1.divide(bd2, 10, RoundingMode.CEILING); \/\/ \u5c0f\u6570\u70b910\u6841\u307e\u3067\u3001\u4e38\u3081\u306f\u5207\u308a\u4e0a\u3052\r\n\r\nSystem.out.println(bd4); \/\/ \u2192 0.3333333333\u3001\u5c0f\u6570\u70b910\u6841\u307e\u3067\u8a08\u7b97\u300111\u6841\u76ee\u3067\u56db\u6368\u4e94\u5165\u3055\u308c\u3066\u3044\u308b\r\nSystem.out.println(bd5); \/\/ \u2192 0.3333333334\u3001\u5c0f\u6570\u70b910\u6841\u307e\u3067\u8a08\u7b97\u300111\u6841\u76ee\u3067\u5207\u308a\u4e0a\u3052\u3055\u308c\u308b<\/pre>\n<p>\u306a\u304a\u3001<span>double<\/span>\u3084<span>float<\/span>\u306a\u3069\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u306e\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3092\u4f7f\u3063\u3066<span>BigDecimal<\/span>\u3092\u751f\u6210\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u304c\u5b9f\u969b\u306b\u6301\u3063\u3066\u3044\u308b\u6570\u5b57\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<span>BigDecimal<\/span>\u3067\u6b63\u78ba\u306b\u6570\u5b57\u3092\u8868\u73fe\u3057\u305f\u3044\u306a\u3089\u3001<span>String<\/span>\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u4f7f\u3046\u306e\u304c\u7121\u96e3\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">BigDecimal bd1 = new BigDecimal(0.1f); \/\/ float\u306e0.1\u3067BigDecimal\u3092\u751f\u6210\u3059\u308b\u3068\u3001\r\nSystem.out.println(bd1); \/\/ \u2192 0.1\u3067\u306f\u306a\u3044!! 0.100000001490116119384765625\r\n\r\nBigDecimal bd2 = new BigDecimal(0.1d); \/\/ double\u306e0.1\u3067BigDecimal\u3092\u751f\u6210\u3059\u308b\u3068\u3001\r\nSystem.out.println(bd2); \/\/ \u2192 0.1\u3067\u306f\u306a\u3044!! 0.1000000000000000055511151231257827021181583404541015625<\/pre>\n<h2><span id=\"i-5\">\uff17\uff0e\u307e\u3068\u3081<\/span><\/h2>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<span>Java<\/span>\u306e<span>double<\/span>\u3092\u304a\u4f1d\u3048\u3057\u3066\u304d\u307e\u3057\u305f\u3002<span>Java<\/span>\u306e<span>double<\/span>\u306f<span>64<\/span>\u30d3\u30c3\u30c8\u306e\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u3067\u3001\u5927\u304d\u306a\u6574\u6570\u304b\u3089\u5c0f\u3055\u306a\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6570\u5b57\u307e\u3067\u3001\u5927\u5909\u5e83\u3044\u7bc4\u56f2\u306e\u5024\u3092\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<span>double<\/span>\u306f<span>Java<\/span>\u3067\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6570\u5b57\u3092\u4f7f\u3046\u6642\u306e\u6a19\u6e96\u3068\u3082\u3044\u3048\u308b\u30c7\u30fc\u30bf\u578b\u3067\u3001\u8a73\u7d30\u306f\u56fd\u969b\u898f\u683c\u306e<span>IEEE 754<\/span>\u3067\u6c7a\u3081\u3089\u308c\u3066\u3044\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>Java\u3067\u306f\u3001<span>double<\/span>\u3068\u3057\u3066\u6271\u3048\u308b\u3082\u306e\u306b\u306f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e<span>double<\/span>\u3068\u3001\u30af\u30e9\u30b9<span>(<\/span>\u53c2\u7167\u578b<span>)<\/span>\u3068\u3057\u3066\u306e<span>Double<\/span>\u306e\u4e8c\u7a2e\u985e\u304c\u3042\u308a\u3001\u305d\u308c\u3089\u306f\u9055\u3046\u3082\u306e\u3067\u3042\u308b\u3053\u3068\u306b\u306f\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002\u305f\u3060\u3001\u30aa\u30fc\u30c8\u30dc\u30af\u30b7\u30f3\u30b0\u306b\u3088\u308a\u9055\u3044\u304c\u898b\u3048\u306b\u304f\u304f\u306f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>double\u306f\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3067<span>2<\/span>\u9032\u6570\u3092\u6271\u3046\u3053\u3068\u306e\u9650\u754c\u30fb\u6ce8\u610f\u70b9\u304c\u3088\u304f\u308f\u304b\u308b\u30c7\u30fc\u30bf\u578b\u3067\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u3089\u306e\u6ce8\u610f\u70b9\u306f\u3069\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3082\u540c\u3058\u3067\u3059\u306e\u3067\u3001<span>Java<\/span>\u3067<span>double<\/span>\u306e\u4f7f\u3044\u65b9\u3092\u3057\u3063\u304b\u308a\u5b66\u3093\u3067\u304a\u3051\u3070\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3082\u305d\u3046\u5927\u304d\u306a\u9055\u3044\u306a\u304f\u4f7f\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u7279\u306b\u6709\u52b9\u6570\u5b57\u3084\u8aa4\u5dee\u306e\u6982\u5ff5\u3001\u8a08\u7b97\u4e0a\u3067\u767a\u751f\u3059\u308b\u554f\u984c\u3078\u306e\u5bfe\u5fdc\u65b9\u6cd5\u3092\u8eab\u306b\u7740\u3051\u3066\u304a\u3051\u3070\u3001\u3044\u3056\u3068\u3044\u3046\u6642\u306b\u5f79\u306b\u7acb\u3064\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u8a08\u7b97\u306f\u82e6\u624b\u3060\u306a\u3041\u3068\u3044\u3046\u65b9\u3082\u3001\u8003\u3048\u65b9\u3060\u3051\u306f\u3057\u3063\u304b\u308a\u899a\u3048\u3066\u304a\u304f\u3068\u3001\u9055\u3044\u306e\u5206\u304b\u308b\u30d7\u30ed\u30b0\u30e9\u30de\u3068\u3057\u3066\u4e00\u76ee\u7f6e\u304b\u308c\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u306edouble\u306f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e\u4e00\u3064\u3067\u3001\u5c0f\u6570\u70b9\u3092\u6301\u3064\u6570\u5b57\u309264\u30d3\u30c3\u30c8\u306e\u7bc4\u56f2\u3067\u8868\u73fe\u3067\u304d\u307e\u3059\u3002 double\u306f\u6d6e\u52d5\u5c0f\u6570\u70b9\u3068\u6307\u6570\u8868\u8a18\u3068\u3044\u3046\u8003\u3048\u65b9\u306e\u304a\u304b\u3052\u3067\u3001\u304a\u3088\u305d10\u306e308\u4e57\u3068\u3044\u3046\u3068\u3066\u3082\u5927\u304d\u306a\u6570\u5b57\u304b\u3089\u300110\u306e\u30de\u30a4\u30ca\u30b9 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":804,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1547"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=1547"}],"version-history":[{"count":7,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1547\/revisions"}],"predecessor-version":[{"id":5794,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1547\/revisions\/5794"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/804"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=1547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=1547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}