--- loncom/homework/caparesponse/caparesponse.pm 2018/09/14 02:51:39 1.260 +++ loncom/homework/caparesponse/caparesponse.pm 2020/12/05 05:01:18 1.262 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.260 2018/09/14 02:51:39 raeburn Exp $ +# $Id: caparesponse.pm,v 1.262 2020/12/05 05:01:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1065,7 +1065,23 @@ sub make_numerical_bubbles { &Math::Random::random_uniform_integer(1,1,10); } for ($ind=0;$ind<$number_of_bubbles;$ind++) { - $bubble_values[$ind] = $answerfactor*($factor**($power-$powers[$#powers-$ind])); + my $exponent = $power-$powers[$#powers-$ind]; + $bubble_values[$ind] = $answerfactor*($factor**$exponent); + + # If bubble is for correct answer (i.e., exponent = 0), and value + # of $answerfactor * factor**$exponent is an integer with more than + # 15 digits, assign $answerfactor itself as bubble value. + # This prevents a "use fewer digits" issue on 64bit servers + # when correct answer is >= 1e+16, and when correct bubble is A. + + if ($exponent == 0) { + if ($bubble_values[$ind] =~ /^-?(\d+)$/) { + if (length($1) > 15) { + $bubble_values[$ind] = $answerfactor; + } + } + } + $bubble_display[$ind] = &format_number($bubble_values[$ind], $format,$target,$safeeval); }