@@ -163,7 +163,7 @@ subtest 'Create numbers with significant digits using Real' => sub {
163163
164164 my $a16 = Real(' 0.' );
165165 is $a16 -> format(' E' ), ' 0E+00' , ' Check the format of 0.' ;
166- is $a16 -> sigfigs, 1, ' 0. has 1 signficant figure' ;
166+ is $a16 -> sigfigs, 1, ' 0. has 1 significant figure' ;
167167 is $a16 -> E, 0, ' The exponential of +00 is 0' ;
168168 is $a16 -> string, ' 0.' , ' The string version is 0.' ;
169169 is $a16 -> TeX, ' {0.}' , ' The TeX version is {0.}' ;
@@ -384,11 +384,37 @@ subtest 'Division' => sub {
384384 is $a2 -> E, -1, ' 1.0000/4.00 = 0.2500 = 2.50 * 10^(-1) (check exp)' ;
385385
386386};
387-
388- # subtest 'Significant Figures for integers' => sub {
389- # # my $a1 = Compute('1.0 * 10^2');
390- # my $a1 = Compute('1.0E+02');
391- # is $a1->format('E'), '1.0E+02', '1.0 * 10^2 internally is 1.0E+02';
392- # };
387+ use Data::Dumper;
388+ subtest ' Significant Figures for integers' => sub {
389+ my $a1 = Compute(' 1.0 x 10^2' );
390+ is $a1 -> format(' E' ), ' 1.0E+02' , ' 1.0 x 10^2 internally is 1.0E+02' ;
391+ is $a1 -> sigfigs, 2, ' 1.0 x 10^2 has 2 significant figures.' ;
392+ is $a1 -> E, 2, ' 1.0 x 10^2 = 1.0 * 10^2 (check exp)' ;
393+
394+ my $a2 = Compute(' 1.0x10^2' );
395+ is $a2 -> format(' E' ), ' 1.0E+02' , ' 1.0 x 10^2 internally is 1.0E+02' ;
396+ is $a2 -> sigfigs, 2, ' 1.0 x 10^2 has 2 significant figures.' ;
397+ is $a2 -> E, 2, ' 1.0 x 10^2 = 1.0 * 10^2 (check exp)' ;
398+
399+ my $a3 = Compute(' 1.234 x 10^8' );
400+ is $a3 -> format(' E' ), ' 1.234E+08' , ' 1.234 x 10^8 internally is 1.234E+08' ;
401+ is $a3 -> sigfigs, 4, ' 1.234 x 10^8 has 4 significant figures.' ;
402+ is $a3 -> E, 8, ' 1.234 x 10^8 = 1.234 * 10^8 (check exp)' ;
403+
404+ my $a4 = Compute(' -1.23 x 10^-4' );
405+ is $a4 -> format(' E' ), ' -1.23E-04' , ' -1.23 x 10^-4 internally is -1.23E-04' ;
406+ is $a4 -> sigfigs, 3, ' -1.23 x 10^-4 has 3 significant figures.' ;
407+ is $a4 -> E, -4, ' -1.23 x 10^-4 = -1.23 * 10^-4 (check exp)' ;
408+
409+ my $a5 = Compute(' 1.23 * 10^3' );
410+ is $a5 -> format(' E' ), ' 1.23E+03' , ' 1.23 * 10^3 internally is 1.23E+03' ;
411+ is $a5 -> sigfigs, 3, ' 1.23 * 10^3 has 3 significant figures.' ;
412+ is $a5 -> E, 3, ' 1.23 * 10^3 = 1.23 * 10^3 (check exp)' ;
413+
414+ my $a6 = Compute(' -3.28*10^5' );
415+ is $a6 -> format(' E' ), ' -3.28E+05' , ' -3.28 * 10^5 internally is -3.28E+05' ;
416+ is $a6 -> sigfigs, 3, ' -3.28 * 10^5 has 3 significant figures.' ;
417+ is $a6 -> E, 5, ' -3.28 * 10^5 = -3.28 * 10^5 (check exp)' ;
418+ };
393419
394420done_testing();
0 commit comments