taken from wiki:Scheme_(programming language)
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 1 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:simon (等级:10 - 炉火纯青,发帖:6859) 发表:2008-09-02 18:19:45  楼主  关注此帖
一个编程的小问题在scheme里面,把数字平方,会出这样的结果: 比如说,平方1.2,结果是1.2100000000000002。 平方3.4,结果是11.559999999999999。 以前在java里面也遇到过这种情形,为什么算出来是这样的结果呢, 明明是个准确值。。。
taken from wiki:Scheme_(programming language)
"The numeric type is further divided into a numerical tower, with subtypes complex, real, rational and integer. (Note that these subtypes are not disjoint; in fact each type is a subset of the previous one). While it is not required that a Scheme implementation support the entire numerical tower, most implementations do. In addition to these traditional properties, Scheme numbers may have the property of "exactness". Integers and rational numbers are exact. An arithmetic operation involving numbers one or more of which is inexact has an inexact result.[1]"

In other words, some implementation of real numbers of scheme is imprecise.
Besides, I don't think Java has such problem.


You may say I'm a dreamer
but I'm not the only one...
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 1 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码