[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm

raeburn raeburn at source.lon-capa.org
Mon Jan 21 01:16:50 EST 2013


raeburn		Mon Jan 21 06:16:50 2013 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  - Bug 6577.
    - Eliminate warnings about significant figures where answer format is set 
      to be S, but correct answer is an integer with multiple trailing zeroes.
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.162 loncom/homework/default_homework.lcpm:1.163
--- loncom/homework/default_homework.lcpm:1.162	Wed Nov 21 23:22:43 2012
+++ loncom/homework/default_homework.lcpm	Mon Jan 21 06:16:50 2013
@@ -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.162 2012/11/21 23:22:43 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.163 2013/01/21 06:16:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1033,6 +1033,17 @@
     $number = abs($number);
     # needed to correct for a number greater than 1 (or
     my $power = ($number < 1) ? 0 : 1;
+    if ($power && $number =~ /^\d+$/) {
+        my $nonzeros = $number;
+        $nonzeros =~ s/0+$//;
+        if (length($number) - length($nonzeros) > 1) {
+            # convert to exponential form
+            my $n = $sig-1;
+            my $numSig = sprintf('%.' . $n . 'E', $number);
+            # return number with sign
+            return $sign.$numSig;
+        }
+    }
     # could round up. Take the integer part of log10.
     my $x10 = int(log($number)/log(10));
     # find number with values left of decimal pt = # of sign figs.




More information about the LON-CAPA-cvs mailing list