# 学习笔记——浮点数的除零

If the argument is {@code 0x7ff0000000000000L}, the result is positive infinity.
If the argument is {@code 0xfff0000000000000L}, the result is negative infinity.
If the argument is any value in the range
* {@code 0x7ff0000000000001L} through
* {@code 0x7fffffffffffffffL} or in the range
* {@code 0xfff0000000000001L} through
* {@code 0xffffffffffffffffL}, the result is a NaN.

Demo：1.0、0.0和0的浮点数值输出：

```double d1 = Double.parseDouble("1.0");
BigDecimal bd1 = new BigDecimal(d1);
System.out.println(bd1);//1

double d2 = Double.parseDouble("0.0");
BigDecimal bd2 = new BigDecimal(d2);
System.out.println(bd2);//0

double d3 = Double.parseDouble("0");
BigDecimal bd3 = new BigDecimal(d3);
System.out.println(bd3);//0```

1）1.0/0的结果是什么？为什么？

Infinity

```double a = 1.0 / 0;
long b = Double.doubleToRawLongBits(a);
System.out.println(b);//9218868437227405312
Long c=0x7ff0000000000000L;
System.out.println(c.longValue());//9218868437227405312```

2）0/0的结果是什么？为什么？

ArithmeticException

原文作者：江河湖泊
原文地址: https://www.cnblogs.com/1693977889zz/p/11632260.html
本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。