<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    石頭JAVA擺地攤兒

    JAVA所有的討論-要一點一點的進步

      BlogJava :: 首頁 ::  :: 聯系 ::  :: 管理 ::
      30 隨筆 :: 0 文章 :: 11 評論 :: 0 Trackbacks
    由于JAVA里沒有sizeof函數,所以想辦法解決一下。

    感謝CSDN網友:dogod

    import java.io.*;

    public class abc {

        
    public static void main(String[] args) {

            
    char cr = 1;
            
    byte be = 1;
            
    short st = 1;
            
    int it = -1;
            
    long lg = 1;
            
    float ft = 1;
            
    double de = 1;

            
    int cnt;
            
    byte x;
            
    int cot = 0;
            
    int byteSize = 0;

            
    // System.out.println("Float.size: "+Float.SIZE);
            
    // System.out.println("Double.size: "+Double.SIZE);

            
    for (cnt = 1; (cr <<= 1!= 0; cnt++)
                ;
            System.out.println(
    "char'sBits:" + cnt);

            
    for (cnt = 1; (be <<= 1!= 0; cnt++)
                ;
            System.out.println(
    "byte'sBits:" + cnt);
            byteSize 
    = cnt;

            
    for (cnt = 1; (st <<= 1!= 0; cnt++)
                ;
            System.out.println(
    "short'sBits:" + cnt);

            
    for (cnt = 1; (it <<= 1!= 0; cnt++)
                ;
            System.out.println(
    "int'sBits:" + cnt);

            
    for (cnt = 1; (lg <<= 1!= 0; cnt++)
                ;
            System.out.println(
    "long'sBits:" + cnt);

            
    // 用字節流處理double
            try {
                ByteArrayOutputStream buf 
    = new ByteArrayOutputStream();
                DataOutputStream out 
    = new DataOutputStream(buf);
                out.writeDouble(de);
                out.close();
                DataInputStream in 
    = new DataInputStream(new ByteArrayInputStream(
                        buf.toByteArray()));

                
    while ((x = (byte) in.readByte()) != -1{

                    
    // System.out.println("byte["+cot+"]:"+x);
                    cot++;
                }

                in.close();

            }
     catch (IOException e) {
                System.out.println(
    "EOF!!!");
            }

            System.out.println(
    "The Double's bit size is :" + cot * byteSize);

            
    // 用字節流處理float
            try {
                cot 
    = 0;
                ByteArrayOutputStream buf 
    = new ByteArrayOutputStream();
                DataOutputStream out 
    = new DataOutputStream(buf);
                out.writeFloat(ft);
                out.close();
                DataInputStream in 
    = new DataInputStream(new ByteArrayInputStream(
                        buf.toByteArray()));

                
    while ((x = (byte) in.readByte()) != -1{

                    
    // System.out.println("byte["+cot+"]:"+x);
                    cot++;
                }

                in.close();

            }
     catch (IOException e) {
                System.out.println(
    "EOF!!!");
            }

            System.out.println(
    "The Float's bit size is :" + cot * byteSize);

        }


    }

    posted on 2006-03-13 13:33 石頭JAVA擺地攤兒 閱讀(741) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 久久亚洲精品成人777大小说| 国产成人免费ā片在线观看老同学| 亚洲短视频在线观看| 亚洲综合成人婷婷五月网址| 亚洲av无码一区二区三区四区| 狼色精品人妻在线视频免费| 国产一区二区三区免费观在线| 97碰公开在线观看免费视频| 免费高清小黄站在线观看| 国产亚洲AV手机在线观看 | 曰批全过程免费视频播放网站| 免费看www视频| 麻豆亚洲AV成人无码久久精品 | 亚洲字幕在线观看| 精品久久久久久国产免费了 | 51精品视频免费国产专区| 亚洲天堂一区二区三区| 欧美在线看片A免费观看| 亚洲色婷婷综合久久| 亚洲色欲色欱wwW在线| 91制片厂制作传媒免费版樱花 | 亚洲自偷自偷在线制服| 一级特黄aa毛片免费观看| 免费一级毛片不卡不收费| 亚洲神级电影国语版| 成人一a毛片免费视频| 亚洲色图在线播放| 中文在线免费看视频| 久久久无码精品亚洲日韩京东传媒| 三级片免费观看久久| 成视频年人黄网站免费视频| 亚洲色图在线播放| 精品久久洲久久久久护士免费| 男人j进女人p免费视频| 国产在线不卡免费播放| 国产亚洲国产bv网站在线| 99re6在线精品视频免费播放 | 曰曰鲁夜夜免费播放视频| 亚洲精彩视频在线观看| 日韩免费高清视频| 亚洲欧美乱色情图片|