Hi, in one of my problems I get an error code saying that / can only be used between (non-negative) integers, code listed below with error message as well.
It throws an error when the variable I at row 22 is negative and is used in division on row 38 and 50. I've tried doing abs() and there is no error.
This problem started occurring after we upgraded from 2.15 to 2.17, tried it on a system with 2.15 installed and got no errors. There seems to be something wrong with pg on my system but it's the latest version and 'npm install' does what it's supposed to do.
This problem is rather old, is there anything deprecated in how we load the macros and/or what macros we use?1 DOCUMENT(); 2 3 # Load whatever macros you need for the problem 4 loadMacros("PG.pl", 5 "PGbasicmacros.pl", 6 "PGchoicemacros.pl", 7 "PGanswermacros.pl", 8 "PGauxiliaryFunctions.pl", 9 "PGgraphmacros.pl", 10 ); 11 12 install_problem_grader(~~&std_problem_grader); 13 14 $A=random(2,6,1); 15 $B=random(2,10,4); 16 $C=random(2,6,1); 17 $D=random(3,11,4); 18 $E=random(2,6,1); 19 $F=random(2,6,1); 20 $G=$A*$B*$E+$C*$D*$F; 21 $H=$A*$F+$C*$E; 22 $I=$E**2*$B-$F**2*$D; 23 $J=$B*$D; 24 25 BEGIN_TEXT 26 $I 27 Skriv uttrycket \(\frac{$A\sqrt{$B}-$C\sqrt{$D}}{$E\sqrt{$B}+$F\sqrt{$D}}\) 28 på formen \(K+L\sqrt{$J}\), där \(K\) och \(L\) är rationella tal. 29 30 $PAR 31 32 \( K = \) \{ans_rule(20) \} 33 34 END_TEXT 35 36 $gcd =gcd($G,$I); 37 $G2=$G/$gcd; 38 $I2=$I/$gcd; 39 $ans = "$G2/$I2"; 40 &ANS(num_cmp($ans,mode=>'frac')); 41 42 BEGIN_TEXT 43 44 \( L = \) \{ans_rule(20) \} 45 46 END_TEXT 47 48 $gcd2 =gcd($H,$I); 49 $H2=$H/$gcd2; 50 $I2=$I/$gcd2; 51 $ans = "-$H2/$I2"; 52 &ANS(num_cmp($ans,mode=>'frac')); 53 54 ENDDOCUMENT();
Problem1 1. ERROR caught by Translator while processing problem file:tmpEdit/talR1.pg **************** ERRORS from evaluating PG file:
You can only use '/' between (non-negative) integers; see position 3 of formula at line 419 of [PG]/macros/PGnumericevaluators.pl Died within main::NUM_CMP called at line 419 of [PG]/macros/PGnumericevaluators.pl from within main::num_cmp called at line 40 of (eval 986)