newLISP Fan Club

Forum => newLISP in the real world => Topic started by: dexter on July 19, 2015, 08:11:05 AM

Title: why the (sub) behavior like this?
Post by: dexter on July 19, 2015, 08:11:05 AM

(sub 1.9 0.2) will work as I thought

but (sub 20000.9 20000.2) will not return 0.7 insead of
0.700000000000728



why not just return 0.7 ??



my newlisp is 10.6.0
Title: Re: why the (sub) behavior like this?
Post by: rrq on July 19, 2015, 02:21:12 PM
Maybe it has something to do with //https://en.wikipedia.org/wiki/Single-precision_floating-point_format

Try
(format "%.30f" 20000.9)
Title: Re: why the (sub) behavior like this?
Post by: dexter on July 19, 2015, 06:04:59 PM
thanks



in the end ,I (mul) the number to be an integer,than I can deal the number with (-)