[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm
raeburn
raeburn at source.lon-capa.org
Tue Jun 24 14:02:47 EDT 2014
raeburn Tue Jun 24 18:02:47 2014 EDT
Modified files:
/loncom/homework default_homework.lcpm
Log:
- Bug 6645.
- "Computer's Answer" - append correct number of trailing zeros to satisfy
significant digits format, in a particular rounding situation.
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.165 loncom/homework/default_homework.lcpm:1.166
--- loncom/homework/default_homework.lcpm:1.165 Tue Jun 24 17:02:33 2014
+++ loncom/homework/default_homework.lcpm Tue Jun 24 18:02:47 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.165 2014/06/24 17:02:33 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.166 2014/06/24 18:02:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1045,6 +1045,18 @@
my $numSig = $xint*10**($x10-$sig+$power);
if ($numSig =~ /^(\d+)\.(\d+)/) {
# insert trailing zero's if have decimal point
+ my @digarray = split('',$1.$2);
+ my $sigcount;
+ while (@digarray > 0) {
+ my $item = shift(@digarray);
+ if ($item) {
+ $sigcount = 1 + @digarray;
+ last;
+ }
+ }
+ if (($sigcount) && ($sig >= $sigcount)) {
+ $zeros = substr($zeros,0,($sig - $sigcount));
+ }
$numSig =~ s/^(\d+)\.(\d+)(\e?(.*)?)$/$1\.$2$zeros$3/;
} else {
if ($numSig =~ /0$/) {
More information about the LON-CAPA-cvs
mailing list