Madhu
10/20/2015 2:07:00 AM
* Günther Thomsen <550a4002-526a-40b2-a63e-923379608b84@googlegroups.com> :
Wrote on Mon, 19 Oct 2015 15:09:52 -0700 (PDT):
| On Wednesday, October 14, 2015 at 8:50:35 AM UTC-7, Madhu wrote:
|> Lispworks for example gives this: (*read-default-float-format* SINGLE-FLOAT)
|>
|> * (truncate 4859165753467 4394484.0)
|> 1105742
|> 144296.0
|>
|> And this is justified because, when you compare single-floats,
|>
|> (= (+ 144296.0 (* 4394484.0 1105742)) 4859165753467e0)
|> ^^^ remainder
|>
|> Given the single-float precision, the remainder can be any number from
|> 0.0 below 262144.0. A professor of IEEE floating point could give a
|> better answer. ---Madhu
|
| but, as Barry Margolin hinted at above, 4859165753467e0 is no single
| float.
It is a single-float because it has an e0 attached at the end and the
reader will read it as a single float.
<snip>
(TRUNCATE N D) => Q, R <==> (= (+ R (* D Q)) N)
|> (multiple-value-bind (q r) (truncate 4859165753467 4394484) (= (+ r
|> (* q 4394484)) 4859165753467))
| T
|
| you'll get
|> (multiple-value-bind (q r) (truncate 4859165753467 4394484.0) (= (+
|> r (* q 4394484)) 4859165753467))
| NIL
This comes out as NIL from the second rule at "12.1.4.1 Rule of Float
and Rational Contagion", when you are comparing a rational with a float.
However the question of compliance has to check from the other
direction: when your mathematical function (eventually) combines a
rational and float..
| but that's because
|> (float 4859165753467)
| 4.8591657e12
This is the same as 4859165753467e0 in the expression I posted.
| hence
|> (multiple-value-bind (q r) (truncate 4859165753467 4394484.0) (= (+
|> r (* q 4394484)) (float 4859165753467)))
| T
Which is the same expresssion I posted above...
| although comparing floats for equality is generally tricky business --
| too easy to lose a bit here and there.
[I checked my posting again, and did not spot any error, I suggest you
read it again to see exactly what I was trying to explain. Regarding
this comment of yours. I tried to show the numeric range of the bits
that are lost.]---Madhu