Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 2
BigDecimalでの数値判断 | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 17
BigDecimalでの数値判断
BigDecimalインスタンス作成時に引数を渡して数値チェックを行います。
この時、Exceptionがスローされれば数値でないことが確認できます。
但し、以下のように引数に0.や0.0や.0を渡した場合、結果は以下のようになります。

import java.math.BigDecimal;

public class sysdt {

    public static void main(String[] args) {
        BigDecimal bd1 = new BigDecimal("0.");
        System.out.println(bd1);
        BigDecimal bd2 = new BigDecimal("0.0");
        System.out.println(bd2);
        BigDecimal bd3 = new BigDecimal(".0");
        System.out.println(bd3);
    }
}
出力結果は以下のように勝手に解釈されるため、BigDecimalで数値の判断をするのが正しいとはいえません。

0
0.0
0.0
コンストラクタ
BigDecimalをインスタンス化する場合、String型をパラメータとして渡しますが、それがnullの場合NullPointerExceptionで落ちますので注意してください。

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 89

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 89

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 98

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/bigdecimal/judge_numeric/judge_numeric.html on line 98