View Single Post
(regarding issue 1)
Posts: n/a
Default (regarding issue 1) - 11-27-2006, 03:03 AM

i've found the source if this the bug in issue 1, and have a solution to fix it:
(at least for equality):
package edu.cmu.cs.stage3.alice.core.question;

/** @deprecated */
public class NumberIsEqualTo extends BinaryNumberResultingInBooleanQuestion {
private static Class[] s_supportedCoercionClasses = { NumberIsNotEqualTo.class, NumberIsGreaterThan.class, NumberIsGreaterThanOrEqualTo.class, NumberIsLessThan.class, NumberIsLessThanOrEqualTo.class };
public Class[] getSupportedCoercionClasses() {
return s_supportedCoercionClasses;
protected boolean getValue( double aValue, double bValue ) {
return aValue == bValue;//NO! don't compare double's this way!!!

1. add the following declaration to the file:
private static final double EPSILON = 0.01d; //limit precision to the amount visible to users
2. change the line i've marked "//NO! ...", from
"return aValue == bValue;//NO! don't compare double's this way!!!"
to the following snippet:
double absoluteDifference =
(aValue < bValue)?(bValue-aValue):(aValue-bValue);
absoluteDifference =
return (absoluteDifference < EPSILON);

of course i can't get the alice2 source code to compile without way too much work, so i won't bother testing this right now, but i believe this would solve the problem.

Last edited by newdok; 11-27-2006 at 03:05 AM. Reason: killed an accidental smiley face
Reply With Quote