{"id":741,"date":"2004-08-22T06:30:00","date_gmt":"2004-08-21T21:30:00","guid":{"rendered":"\/?p=741"},"modified":"2004-08-22T06:30:00","modified_gmt":"2004-08-21T21:30:00","slug":"ieee-754-floating-point","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/741.html","title":{"rendered":"IEEE 754 floating-point"},"content":{"rendered":"<p>IEEE 754 floating-point &#8220;double format&#8221; \u30d3\u30c3\u30c8\u30ec\u30a4\u30a2\u30a6\u30c8\u304c\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u3092\u8868\u793a\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002<br \/>\n\u7b26\u53f7\u90e8\u306f\u6b63\u306e\u6570\u3060\u30680\u3067\u8ca0\u306e\u6570\u3060\u30681\u304c\u5165\u308a\u3001\u6307\u6570\u90e8\u306b\u5165\u3063\u3066\u3044\u308b\u5024\u306b\u306f1023\u304c\u52a0\u7b97\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3060\u3002\u4eee\u6570\u90e8\u306b\u306f\u5c0f\u6570\u90e8\u5206\u304c2\u9032\u6570\u3067\u5165\u3063\u3066\u3044\u308b\u306e\u30671\u3092\u52a0\u7b97\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3088\u3046\u3060\u3002\u3068\u308a\u3042\u3048\u305a\u30011E1\u306e\u5024\u3092\u77e5\u308a\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u305d\u308c\u306810\u306e\u5185\u90e8\u8868\u73fe\u304c\u4e00\u81f4\u3057\u3066\u3044\u305f\u3053\u3068\u3060\u3051\u306f\u78ba\u8a8d\u3057\u305f\u304c\u3001\u305d\u306e\u4ed6\u306e\u4e8b\u9805\u306b\u3064\u3044\u3066\u306f\u307e\u3060\u672a\u78ba\u8a8d\u306a\u70b9\u304c\u591a\u3044\u30021.0, 2.0, 4.0, 0.5, 0.25\u3042\u305f\u308a\u3092\u8a66\u3059\u3068\u826f\u3055\u305d\u3046\u3060\u3002\u6307\u6570\u90e8\u306e\u5024\u306b\u3088\u3063\u3066\u6b63\u898f\u5316\u6570\u304b\u975e\u6b63\u898f\u5316\u6570\u304b\u304c\u6c7a\u307e\u3063\u3066\u3001\u8a08\u7b97\u304c\u5909\u308f\u308b\u3089\u3057\u3044\u3053\u3068\u307e\u3067\u306f\u308f\u304b\u3063\u305f\u304c\u3001\u7720\u304f\u306a\u3063\u305f\u306e\u3067\u8a73\u7d30\u306f\u307e\u3060\u307f\u3066\u3044\u306a\u3044\u3002\u306a\u3093\u3068\u306a\u304f\u6b63\u898f\u5316\u6570\u306b\u3064\u3044\u3066\u306f\u5bfe\u5fdc\u3067\u304d\u3066\u3044\u305d\u3046\u3060\u304c\u975e\u6b63\u898f\u5316\u6570\u306f\u99c4\u76ee\u305d\u3046\u3002\u307e\u3060\u307e\u3060\u3064\u3081\u304c\u7518\u305d\u3046\u3060\u3002<\/p>\n<p>\n\u3068\u601d\u3044\u306a\u304c\u3089JavaFAQ\u3092\u898b\u308b\u3068\u3001<a href=\"http:\/\/www.gimlay.org\/~javafaq\/S029.html#S029-08\">\u6d6e\u52d5\u5c0f\u6570\u306e\u8868\u8a18\u65b9\u6cd5\u3092\u793a\u3059 IEEE754 \u3068\u306f\u4f55\u3067\u3059\u304b\uff1f<\/a>\u3068\u3044\u3046\u8cea\u554f\u3068\u7b54\u304c\u3001\u305a\u3070\u308a\u8f09\u3063\u3066\u3044\u305f\u3002&#8230;\u7d20\u6674\u3089\u3057\u3044\u3067\u3059JavaFAQ&#8230; \u3067\u3082\u6307\u6570\u90e8\u30671023\u3092\u5f15\u3044\u3066\u3044\u306a\u3044\u30d0\u30b0\u3068\u975e\u6b63\u898f\u5316\u6570\u306e\u8003\u616e\u304c\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3092\u767a\u898b\u3002\u6307\u6458\u3057\u3066\u304a\u304f\u306e\u304c\u3044\u3044\u306e\u3060\u308d\u3046\u3051\u3069\u3001\u6d3b\u52d5\u505c\u6b62\u3057\u3066\u3044\u308b\u304b\u3089\u3069\u3046\u3057\u3088\u3046&#8230;\u3068\u308a\u3042\u3048\u305aML\u306b\u306f\u6295\u7a3f\u3057\u3066\u304a\u3044\u305f\u3002\n<\/p>\n<p><!--more--><\/p>\n<div class=\"code\">public class ParseDouble {<br \/>\n    private double d;<br \/>\n    private boolean sign; \/\/ true:plus or zero\/false:minus<br \/>\n    private long exponent;<br \/>\n    private String mantissa;<br \/>\n    private String longBit;<\/p>\n<p>    public ParseDouble(String s) {<br \/>\n\td = Double.parseDouble(s);<br \/>\n\tlongBit = Long.toBinaryString(Double.doubleToLongBits(d));<br \/>\n\tint longBitLength = longBit.length();<br \/>\n\tfor (int i=64 ; i>longBitLength ; i&#8211;) {<br \/>\n\t    longBit = &#8220;0&#8221;+longBit;<br \/>\n\t}<br \/>\n\tString ssign = longBit.substring(0, 1);<br \/>\n\tif (d == 0) { sign = true; }<br \/>\n\telse if ( &#8220;0&#8221;.equals(ssign) ) { sign = true; }<br \/>\n\telse { sign = false; }<br \/>\n\ts = longBit.substring(1, 12);<br \/>\n\texponent = Long.valueOf(s, 2).longValue() &#8211; 1023;<br \/>\n\tmantissa = &#8220;1.&#8221;+longBit.substring(12, 64);<br \/>\n    }<br \/>\n    public double getData() { return d; }<br \/>\n    public String getLongBit() { return longBit; }<br \/>\n    public boolean getSign() { return sign; }<br \/>\n    public long getExponent() { return exponent; }<br \/>\n    public String getMantissa() { return mantissa; }<\/p>\n<p>    public static void main(String[] args) {<br \/>\n\tParseDouble d = new ParseDouble(args[0]);<\/p>\n<p>\tSystem.out.println(&#8220;data:&#8221;+d.getData());<br \/>\n\tSystem.out.println(&#8220;bit image:&#8221;);<br \/>\n\tSystem.out.print(&#8220;&#8212;6&#8221;);<br \/>\n\tSystem.out.print(&#8220;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IEEE 754 floating-point &#8220;double format&#8221; \u30d3\u30c3\u30c8\u30ec\u30a4\u30a2\u30a6\u30c8\u304c\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u3092\u8868\u793a\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002 \u7b26\u53f7\u90e8\u306f\u6b63\u306e\u6570\u3060\u30680\u3067\u8ca0\u306e\u6570\u3060\u30681\u304c\u5165\u308a\u3001\u6307 &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/741.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-741","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=741"}],"version-history":[{"count":0,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/741\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}