Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

计算机里表示浮点数是有误差的,不像数学

Posted by hawk at 2005-03-31 13:41:29 on Problem 1001
In Reply To:cout<<0.1*0.1-0.01<<endl;为什么等于1.73472e-018? Posted by:00 at 2005-03-30 13:50:18
0.1*0.1之后的结果,在计算机中是一个非常非常接近.01的数
减去.01后,就是一个非常接近0的数
所以浮点判断是否相等,不该直接用==来比较
而是看他们差的绝对值是不是足够接近0

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator