[Vm-dev] failing/errors Pharo Tests with CogVM

Andreas Raab andreas.raab at gmx.de
Fri Sep 17 05:54:57 UTC 2010

On 9/16/2010 2:44 PM, Eliot Miranda wrote:
>      I realise we need to be more precise.  Are you talking about NaNs
> specifically or NaN and Inf?

NaN only. +-Inf are fine as they have a well-defined mathematical 
relationship over the set of numbers. NaN does not.

> The Squeak VM happily answers Inf from its
> float primitives.  In fact the only guard against a NaN or Inf result
> being produced by the floating-point primitives is the guard against
> dividing by zero.  But e.g. in the interpreter (1.0e300 / 1.0e-300)
> isInfinite and there is no failure.  So specifically failing for aFloat
> / 0.0 seems a bit of a fig leaf to me.
> So what would your ideal semantics be?
> a) - fail whenever the result is Inf or NaN?
> b) - fail whenever the result is NaN and allow aFloat / 0.0 to answer Inf
> c) - fail whenever the result is NaN but fail aFloat / 0.0
> d) - the Interpreter status quo, fail only for aFloat / 0.0
> e) - never fail and answer Nan and Inf as specified in IEEE 754
> The situation with VW before IEEE was that it did a) and we changed it
> so that the mode switch selected either a) or e), with, IIRC, the
> current default being e).

f) Fail whenever the result is NaN or when dividing by zero.

My preference for f) is that division by zero should be consistent 
between floating point numbers and integers. It would be strange if "1 / 
0" => boom but "1.0 / 0" => Inf or "1 / 0.0" => Inf. *However* underflow 
isn't division by zero and may silently result in Inf. In other words:

	self should:[1.0 / 0.0] raise: ZeroDivide.

but (#successor produces the smallest float larger than the receiver)

	self shouldnt:[1.0 / 0.0 successor] raise: Error.
	self assert: (1.0 / 0.0 successor) = Float infinity.

  - Andreas

More information about the Vm-dev mailing list