一个编程的小问题在scheme里面,把数字平方,会出这样的结果:
比如说,平方1.2,结果是1.2100000000000002。
平方3.4,结果是11.559999999999999。
以前在java里面也遇到过这种情形,为什么算出来是这样的结果呢,
明明是个准确值。。。
试试把1.2转换成二进制数
in IEEE standard, the double precision number 1.2 is represented by 0x3ff3333333333333 (8byte), and you have a round-off error.
for more details:
http://en.wikipedia.org/wiki/IEEE_754
for more details:
http://en.wikipedia.org/wiki/IEEE_754