亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? format.java

?? java 核心技術 第七版 源碼 學習 J2SE
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
      if (precision < 0) precision = 6;
      int s = 1;
      if (x < 0) { x = -x; s = -1; }
      if (Double.isNaN(x)) r = "NaN";
      else if (x == Double.POSITIVE_INFINITY) r = "Inf";
      else if (fmt == 'f')
         r = fixedFormat(x);
      else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G')
         r = expFormat(x);
      else throw new java.lang.IllegalArgumentException();

      return pad(sign(s, r));
   }

   /**
      Formats an integer into a string (like sprintf in C)
      @param x the number to format
      @return the formatted string
   */
   public String format(int x)
   {
      long lx = x;
      if (fmt == 'o' || fmt == 'x' || fmt == 'X')
         lx &= 0xFFFFFFFFL;
      return format(lx);
   }

   /**
      Formats a long integer into a string (like sprintf in C)
      @param x the number to format
      @return the formatted string
   */
   public String format(long x)
   {
      String r;
      int s = 0;
      if (fmt == 'd' || fmt == 'i')
      {
         if (x < 0)
         {
            r = ("" + x).substring(1);
            s = -1;
         }
         else
         {
            r = "" + x;
            s = 1;
         }
      }
      else if (fmt == 'o')
         r = convert(x, 3, 7, "01234567");
      else if (fmt == 'x')
         r = convert(x, 4, 15, "0123456789abcdef");
      else if (fmt == 'X')
         r = convert(x, 4, 15, "0123456789ABCDEF");
      else throw new java.lang.IllegalArgumentException();

      return pad(sign(s, r));
   }

   /**
      Formats a character into a string (like sprintf in C)
      @param x the value to format
      @return the formatted string
   */
   public String format(char c)
   {
      if (fmt != 'c')
         throw new java.lang.IllegalArgumentException();

      String r = "" + c;
      return pad(r);
   }

   /**
      Formats a string into a larger string (like sprintf in C)
      @param x the value to format
      @return the formatted string
   */
   public String format(String s)
   {
      if (fmt != 's')
         throw new java.lang.IllegalArgumentException();
      if (precision >= 0 && precision < s.length())
         s = s.substring(0, precision);
      return pad(s);
   }


   /**
      a test stub for the format class
   */
   public static void main(String[] a)
   {
      double x = 1.23456789012;
      double y = 123;
      double z = 1.2345e30;
      double w = 1.02;
      double u = 1.234e-5;
      int d = 0xCAFE;
      Format.printf("x = |%f|\n", x);
      Format.printf("u = |%20f|\n", u);
      Format.printf("x = |% .5f|\n", x);
      Format.printf("w = |%20.5f|\n", w);
      Format.printf("x = |%020.5f|\n", x);
      Format.printf("x = |%+20.5f|\n", x);
      Format.printf("x = |%+020.5f|\n", x);
      Format.printf("x = |% 020.5f|\n", x);
      Format.printf("y = |%#+20.5f|\n", y);
      Format.printf("y = |%-+20.5f|\n", y);
      Format.printf("z = |%20.5f|\n", z);

      Format.printf("x = |%e|\n", x);
      Format.printf("u = |%20e|\n", u);
      Format.printf("x = |% .5e|\n", x);
      Format.printf("w = |%20.5e|\n", w);
      Format.printf("x = |%020.5e|\n", x);
      Format.printf("x = |%+20.5e|\n", x);
      Format.printf("x = |%+020.5e|\n", x);
      Format.printf("x = |% 020.5e|\n", x);
      Format.printf("y = |%#+20.5e|\n", y);
      Format.printf("y = |%-+20.5e|\n", y);

      Format.printf("x = |%g|\n", x);
      Format.printf("z = |%g|\n", z);
      Format.printf("w = |%g|\n", w);
      Format.printf("u = |%g|\n", u);
      Format.printf("y = |%.2g|\n", y);
      Format.printf("y = |%#.2g|\n", y);

      Format.printf("d = |%d|\n", d);
      Format.printf("d = |%20d|\n", d);
      Format.printf("d = |%020d|\n", d);
      Format.printf("d = |%+20d|\n", d);
      Format.printf("d = |% 020d|\n", d);
      Format.printf("d = |%-20d|\n", d);
      Format.printf("d = |%20.8d|\n", d);
      Format.printf("d = |%x|\n", d);
      Format.printf("d = |%20X|\n", d);
      Format.printf("d = |%#20x|\n", d);
      Format.printf("d = |%020X|\n", d);
      Format.printf("d = |%20.8x|\n", d);
      Format.printf("d = |%o|\n", d);
      Format.printf("d = |%020o|\n", d);
      Format.printf("d = |%#20o|\n", d);
      Format.printf("d = |%#020o|\n", d);
      Format.printf("d = |%20.12o|\n", d);

      Format.printf("s = |%-20s|\n", "Hello");
      Format.printf("s = |%-20c|\n", '!');

      // regression test to confirm fix of reported bugs

      Format.printf("|%i|\n", Long.MIN_VALUE);

      Format.printf("|%6.2e|\n", 0.0);
      Format.printf("|%6.2g|\n", 0.0);

      Format.printf("|%6.2f|\n", 9.99);
      Format.printf("|%6.2f|\n", 9.999);
      Format.printf("|%.2f|\n", 1.999);

      Format.printf("|%6.0f|\n", 9.999);
      Format.printf("|%20.10s|\n", "Hello");
      d = -1;
      Format.printf("-1 = |%X|\n", d);

      Format.printf("100 = |%e|\n", 100.0); // 2000-06-09
      Format.printf("1/0 = |%f|\n", 1.0 / 0.0);
      Format.printf("-1/0 = |%e|\n", -1.0 / 0.0);
      Format.printf("0/0 = |%g|\n", 0.0 / 0.0);
   }

   private static String repeat(char c, int n)
   {
      if (n <= 0) return "";
      StringBuffer s = new StringBuffer(n);
      for (int i = 0; i < n; i++) s.append(c);
      return s.toString();
   }

   private static String convert(long x, int n, int m, String d)
   {
      if (x == 0) return "0";
      String r = "";
      while (x != 0)
      {
         r = d.charAt((int)(x & m)) + r;
         x = x >>> n;
      }
      return r;
   }

   private String pad(String r)
   {
      String p = repeat(' ', width - r.length());
      if (leftAlign) return pre + r + p + post;
      else return pre + p + r + post;
   }

   private String sign(int s, String r)
   {
      String p = "";
      if (s < 0) p = "-";
      else if (s > 0)
      {
         if (showPlus) p = "+";
         else if (showSpace) p = " ";
      }
      else
      {
         if (fmt == 'o' && alternate && r.length() > 0 && r.charAt(0) != '0') p = "0";
         else if (fmt == 'x' && alternate) p = "0x";
         else if (fmt == 'X' && alternate) p = "0X";
      }
      int w = 0;
      if (leadingZeroes)
         w = width;
      else if ((fmt == 'd' || fmt == 'i' || fmt == 'x' || fmt == 'X' || fmt == 'o')
         && precision > 0) w = precision;

      return p + repeat('0', w - p.length() - r.length()) + r;
   }

   private String fixedFormat(double d)
   {
      boolean removeTrailing
         = (fmt == 'G' || fmt == 'g') && !alternate;
         // remove trailing zeroes and decimal point

      if (d > 0x7FFFFFFFFFFFFFFFL) return expFormat(d);
      if (precision == 0)
         return (long)(d + 0.5) + (removeTrailing ? "" : ".");

      long whole = (long)d;
      double fr = d - whole; // fractional part
      if (fr >= 1 || fr < 0) return expFormat(d);

      double factor = 1;
      String leadingZeroes = "";
      for (int i = 1; i <= precision && factor <= 0x7FFFFFFFFFFFFFFFL; i++)
      {
         factor *= 10;
         leadingZeroes = leadingZeroes + "0";
      }
      long l = (long) (factor * fr + 0.5);
      if (l >= factor) { l = 0; whole++; } // CSH 10-25-97

      String z = leadingZeroes + l;
      z = "." + z.substring(z.length() - precision, z.length());

      if (removeTrailing)
      {
         int t = z.length() - 1;
         while (t >= 0 && z.charAt(t) == '0') t--;
         if (t >= 0 && z.charAt(t) == '.') t--;
         z = z.substring(0, t + 1);
      }

      return whole + z;
   }

   private String expFormat(double d)
   {
      String f = "";
      int e = 0;
      double dd = d;
      double factor = 1;
      if (d != 0)
      {
         while (dd >= 10) { e++; factor /= 10; dd = dd / 10; } // 2000-06-09
         while (dd < 1) { e--; factor *= 10; dd = dd * 10; }
      }
      if ((fmt == 'g' || fmt == 'G') && e >= -4 && e < precision)
         return fixedFormat(d);

      d = d * factor;
      f = f + fixedFormat(d);

      if (fmt == 'e' || fmt == 'g')
         f = f + "e";
      else
         f = f + "E";

      String p = "000";
      if (e >= 0)
      {
         f = f + "+";
         p = p + e;
      }
      else
      {
         f = f + "-";
         p = p + (-e);
      }

      return f + p.substring(p.length() - 3, p.length());
   }

   private int width;
   private int precision;
   private String pre;
   private String post;
   private boolean leadingZeroes;
   private boolean showPlus;
   private boolean alternate;
   private boolean showSpace;
   private boolean leftAlign;
   private char fmt; // one of cdeEfgGiosxXos
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区视频| 97久久精品人人爽人人爽蜜臀| 欧美日韩三级一区| 亚洲午夜av在线| 777亚洲妇女| 久久精品国产一区二区| 精品欧美黑人一区二区三区| 极品销魂美女一区二区三区| 久久精品夜色噜噜亚洲aⅴ| 成人午夜激情视频| 亚洲精品国产一区二区三区四区在线 | 亚洲欧美一区二区三区孕妇| 欧美在线观看视频在线| 奇米777欧美一区二区| 国产亚洲精品超碰| 色综合久久中文综合久久牛| 日本中文在线一区| 国产亚洲一区字幕| 在线欧美一区二区| 九九视频精品免费| 亚洲天堂网中文字| 欧美xxxxxxxxx| 99久久免费精品| 日本91福利区| 国产精品国产自产拍高清av| 欧美视频一区二区三区在线观看| 久久精品国产成人一区二区三区| 国产精品初高中害羞小美女文| 欧美精品 国产精品| 国产精品99久久久| 一区二区欧美国产| 久久丝袜美腿综合| 欧美日韩在线播放一区| 国产福利一区二区三区视频在线 | 亚洲成人在线网站| 欧美国产精品专区| 日韩午夜av电影| 91毛片在线观看| 黄页视频在线91| 无码av免费一区二区三区试看 | 国产精品国产三级国产三级人妇| 欧美一级精品大片| 91啦中文在线观看| 国产乱码字幕精品高清av | 欧美一区二区三区日韩视频| 成人激情免费电影网址| 日本sm残虐另类| 亚洲无人区一区| 国产精品毛片久久久久久| 日韩欧美久久一区| 精品视频在线免费看| av中文字幕在线不卡| 国产在线播精品第三| 日韩精品成人一区二区三区| 亚洲免费在线视频一区 二区| 久久综合五月天婷婷伊人| 欧美在线不卡视频| 色av一区二区| 91年精品国产| 白白色亚洲国产精品| 国产精品资源在线| 激情六月婷婷久久| 久久超碰97人人做人人爱| 日本中文字幕一区二区视频 | 国产精品久久久久久久午夜片| 日韩女优制服丝袜电影| 欧美三级乱人伦电影| 欧美伊人久久大香线蕉综合69| 波多野结衣在线一区| 国产风韵犹存在线视精品| 韩国v欧美v日本v亚洲v| 免费亚洲电影在线| 热久久国产精品| 久久精品国产久精国产| 久久机这里只有精品| 久久精品国产99| 精品一区二区三区久久| 激情综合色综合久久综合| 精品夜夜嗨av一区二区三区| 久久国产三级精品| 国产精品一品视频| 韩国欧美一区二区| 另类小说视频一区二区| 亚洲精品少妇30p| 日本丶国产丶欧美色综合| 91免费观看国产| 欧美在线一二三| 欧美日韩国产免费一区二区| 欧美日韩一区二区三区不卡| 欧美日韩www| 欧美va日韩va| 国产三级精品三级| 亚洲欧美日韩国产手机在线| 依依成人综合视频| 日韩高清电影一区| 经典一区二区三区| eeuss影院一区二区三区| 欧亚洲嫩模精品一区三区| 欧美日韩中文另类| 337p粉嫩大胆噜噜噜噜噜91av| 精品福利在线导航| 国产精品女同一区二区三区| 一区二区三区在线高清| 视频一区二区国产| 国产91精品一区二区麻豆网站 | 黄网站免费久久| bt7086福利一区国产| 欧美久久久久免费| 国产亚洲精品资源在线26u| 亚洲日穴在线视频| 六月丁香综合在线视频| 成人午夜免费视频| 911精品产国品一二三产区| 国产午夜精品美女毛片视频| 亚洲一卡二卡三卡四卡五卡| 久久精品二区亚洲w码| 不卡的电影网站| 日韩色在线观看| 亚洲天堂av老司机| 蓝色福利精品导航| 日本电影欧美片| 国产视频一区不卡| 婷婷中文字幕一区三区| 国产精品日日摸夜夜摸av| 国产成人免费在线视频| 青娱乐精品在线视频| 国产99久久精品| 欧美精品在线观看播放| 国产欧美日韩激情| 三级一区在线视频先锋| 波多野结衣中文字幕一区| 久久中文娱乐网| 亚洲成人免费看| 不卡视频一二三四| 精品剧情v国产在线观看在线| 亚洲精品乱码久久久久久| 国产成人精品一区二区三区四区 | 91久久国产综合久久| 久久久99免费| 日本免费在线视频不卡一不卡二| www.欧美亚洲| 久久综合色婷婷| 香蕉加勒比综合久久| 色狠狠一区二区三区香蕉| 中文欧美字幕免费| 国产一区二区三区不卡在线观看| 欧美日本免费一区二区三区| 亚洲图片你懂的| 国产91精品精华液一区二区三区| 日韩情涩欧美日韩视频| 性做久久久久久免费观看欧美| 成人国产精品免费| 久久亚洲一区二区三区四区| 青青草成人在线观看| 3atv一区二区三区| 亚洲18影院在线观看| 欧美性大战久久久| 亚洲午夜精品在线| 欧美中文字幕久久 | 亚洲国产综合91精品麻豆| av在线不卡免费看| 中文字幕欧美激情| 国产成a人亚洲| 国产日韩精品一区| 不卡免费追剧大全电视剧网站| 久久久久久夜精品精品免费| 韩国成人精品a∨在线观看| 欧美精品一区二区三区蜜桃| 蜜臀av一级做a爰片久久| 在线播放91灌醉迷j高跟美女| 亚洲成人av一区二区| 这里只有精品99re| 另类的小说在线视频另类成人小视频在线| 欧美日韩一区国产| 日本中文字幕一区二区视频| 56国语精品自产拍在线观看| 毛片基地黄久久久久久天堂| 日韩美女一区二区三区四区| 国产一区免费电影| 亚洲国产精品ⅴa在线观看| eeuss影院一区二区三区 | 亚洲国产精华液网站w| 成人污污视频在线观看| 亚洲人成网站影音先锋播放| 在线观看一区日韩| 视频一区视频二区中文| 精品久久久久久久久久久院品网 | 美脚の诱脚舐め脚责91| 国产日韩欧美亚洲| 色婷婷久久久久swag精品| 午夜电影一区二区| 欧美一区二区视频在线观看| 国产精品正在播放| 一区二区三区在线播| 91麻豆精品国产综合久久久久久| 精品伊人久久久久7777人| 国产精品乱码人人做人人爱| 欧美性淫爽ww久久久久无| 激情久久五月天| 亚洲欧美日本韩国|