<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擺地攤兒 閱讀(736) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品免费网站| 国产免费牲交视频| 亚洲综合中文字幕无线码| 最新猫咪www免费人成| 男性gay黄免费网站| 亚洲AV无码精品色午夜果冻不卡| 日本免费一区二区在线观看| 美女免费精品高清毛片在线视| 亚洲精品无码不卡在线播放HE| 成年在线观看网站免费| 一级做a爰片久久毛片免费看 | 国产性生交xxxxx免费| 免费在线观影网站| 亚洲熟妇AV乱码在线观看| 国产美女亚洲精品久久久综合| 18禁网站免费无遮挡无码中文| 一区视频免费观看| 国产成人精品亚洲日本在线| 国产性爱在线观看亚洲黄色一级片| 国产一卡二卡四卡免费| 成人免费av一区二区三区| 99亚偷拍自图区亚洲| 精品国产综合成人亚洲区| 午夜dj免费在线观看| 一级毛片成人免费看免费不卡| 亚洲AV一区二区三区四区| 久久精品国产亚洲av高清漫画| 免费人妻av无码专区| 亚洲网站在线免费观看| 国产精品1024在线永久免费| 亚洲日韩国产AV无码无码精品| 亚洲AV无码一区东京热| 亚洲av午夜成人片精品电影| 青春禁区视频在线观看直播免费 | 国产成人在线观看免费网站| 久久久久久夜精品精品免费啦 | 中文字幕一区二区免费| 亚洲精品色在线网站| 亚洲激情视频图片| 亚洲伊人tv综合网色| 亚洲日韩精品一区二区三区 |