In the Fraction context, when allowProperFractions is set, 0 a/b is interpreted as -a/b. For example, in the following example, 0 1/6 is marked correct, while the correct answer is -1/6.

Am I doing something wrong?

Thanks,

Adam

########################################################################

DOCUMENT();

loadMacros(

"PGstandard.pl", # Standard macros for PG language

"MathObjects.pl",

"contextFraction.pl",

#"source.pl", # allows code to be displayed on certain sites.

#"PGcourse.pl", # Customization file for the course

);

# Print problem number and point value (weight) for the problem

TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect

$showPartialCorrectAnswers = 1;

Context("Fraction");

Context()->flags->set(allowProperFractions=>1);

$a = Compute("1/2");

$b = Compute("1/3");

$ans = Compute(-$a*$b);

Context()->texStrings;

BEGIN_TEXT

\(-$a * $b \) \{ans_rule(35)\}

END_TEXT

Context()->normalStrings;

ANS($ans->cmp());

ENDDOCUMENT();

### Bug (?) in Fraction context with mixed numbers of the form 0 a/b

by Adam Weyhaupt -
In reply to Adam Weyhaupt
Sunday, 7 February 2010, 12:46 AM

### Re: Bug (?) in Fraction context with mixed numbers of the form 0 a/b

by Adam Weyhaupt -
I guess that the problems is in contextFraction.pl.

Instead of

#

# For proper fractions, add the integer to the fraction

#

sub _eval {

my ($self,$a,$b)= @_;

return ($a > 0 ? $a + $b : $a - $b);

}

it should be

#

# For proper fractions, add the integer to the fraction

#

sub _eval {

my ($self,$a,$b)= @_;

return ($a >= 0 ? $a + $b : $a - $b);

}

Adam

Instead of

#

# For proper fractions, add the integer to the fraction

#

sub _eval {

my ($self,$a,$b)= @_;

return ($a > 0 ? $a + $b : $a - $b);

}

it should be

#

# For proper fractions, add the integer to the fraction

#

sub _eval {

my ($self,$a,$b)= @_;

return ($a >= 0 ? $a + $b : $a - $b);

}

Adam

In reply to Adam Weyhaupt
Sunday, 7 February 2010, 5:47 AM

### Re: Bug (?) in Fraction context with mixed numbers of the form 0 a/b

by Davide Cervone -
Good detective work. I've updated the contextFraction.pl macro file with this correction. Thanks!

Davide

Davide