3*0.1 == 0.3 返回 true还是 false

3*0.1 == 0.3 返回 true还是 false

返回false因为有些浮点数不能完全精确的表示出来
例如:

1---------------------
1*0.1=0.1
1*0.2=0.2
1*0.3=0.3
1*0.4=0.4
1*0.5=0.5
1*0.6=0.6
1*0.7=0.7
1*0.8=0.8
1*0.9=0.9
1*1.0=1.0
2---------------------
2*0.1=0.2
2*0.2=0.4
2*0.3=0.6
2*0.4=0.8
2*0.5=1.0
2*0.6=1.2
2*0.7=1.4
2*0.8=1.6
2*0.9=1.8
2*1.0=2.0
3---------------------
3*0.1=0.30000000000000004
3*0.2=0.6000000000000001
3*0.3=0.8999999999999999
3*0.4=1.2000000000000002
3*0.5=1.5
3*0.6=1.7999999999999998
3*0.7=2.0999999999999996
3*0.8=2.4000000000000004
3*0.9=2.7
3*1.0=3.0
4---------------------
4*0.1=0.4
4*0.2=0.8
4*0.3=1.2
4*0.4=1.6
4*0.5=2.0
4*0.6=2.4
4*0.7=2.8
4*0.8=3.2
4*0.9=3.6
4*1.0=4.0
5---------------------
5*0.1=0.5
5*0.2=1.0
5*0.3=1.5
5*0.4=2.0
5*0.5=2.5
5*0.6=3.0
5*0.7=3.5
5*0.8=4.0
5*0.9=4.5
5*1.0=5.0
6---------------------
6*0.1=0.6000000000000001
6*0.2=1.2000000000000002
6*0.3=1.7999999999999998
6*0.4=2.4000000000000004
6*0.5=3.0
6*0.6=3.5999999999999996
6*0.7=4.199999999999999
6*0.8=4.800000000000001
6*0.9=5.4
6*1.0=6.0
7---------------------
7*0.1=0.7000000000000001
7*0.2=1.4000000000000001
7*0.3=2.1
7*0.4=2.8000000000000003
7*0.5=3.5
7*0.6=4.2
7*0.7=4.8999999999999995
7*0.8=5.6000000000000005
7*0.9=6.3
7*1.0=7.0
8---------------------
8*0.1=0.8
8*0.2=1.6
8*0.3=2.4
8*0.4=3.2
8*0.5=4.0
8*0.6=4.8
8*0.7=5.6
8*0.8=6.4
8*0.9=7.2
8*1.0=8.0
9---------------------
9*0.1=0.9
9*0.2=1.8
9*0.3=2.6999999999999997
9*0.4=3.6
9*0.5=4.5
9*0.6=5.3999999999999995
9*0.7=6.3
9*0.8=7.2
9*0.9=8.1
9*1.0=9.0
10---------------------
10*0.1=1.0
10*0.2=2.0
10*0.3=3.0
10*0.4=4.0
10*0.5=5.0
10*0.6=6.0
10*0.7=7.0
10*0.8=8.0
10*0.9=9.0
10*1.0=10.0




已标记关键词 清除标记
相关推荐
<p> <b><span style="background-color:#FFE500;">【超实用课程内容】</span></b> </p> <p> <br /> </p> <p> <br /> </p> <p> 本课程内容包含讲解<span>解读Nginx的基础知识,</span><span>解读Nginx的核心知识、带领学员进行</span>高并发环境下的Nginx性能优化实战,让学生能够快速将所学融合到企业应用中。 </p> <p> <br /> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b><br /> </b> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b><span style="background-color:#FFE500;">【课程如何观看?】</span></b> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> PC端:<a href="https://edu.csdn.net/course/detail/26277"><span id="__kindeditor_bookmark_start_21__"></span></a><a href="https://edu.csdn.net/course/detail/27216">https://edu.csdn.net/course/detail/27216</a> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 移动端:CSDN 学院APP(注意不是CSDN APP哦) </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 本课程为录播课,课程永久有效观看时长,大家可以抓紧时间学习后一起讨论哦~ </p> <p style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <br /> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <strong><span style="background-color:#FFE500;">【学员专享增值服务】</span></strong> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b>源码开放</b> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 下载方式:电脑登录<a href="https://edu.csdn.net/course/detail/26277"></a><a href="https://edu.csdn.net/course/detail/27216">https://edu.csdn.net/course/detail/27216</a>,播放页面右侧点击课件进行资料打包下载 </p> <p> <br /> </p> <p> <br /> </p> <p> <br /> </p>
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页