[LON-CAPA-users] nS in &format

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Thu, 7 Jul 2005 18:24:53 -0400 (EDT)

Hi Joe,

> #Enter the computations here
> $a=&format(&random(1.00,9.99,0.10),'2f');
> $b=58.44;
> $c=$a*$b;
> $c=&format($c, '3s');
> The script above will display 3 significant figures but it does not round 
> up.  If I use 2e instead of 3s, it displays x.xxEx with the exponential 
> number rounded properly.


running this here:
  <script type="loncapa/perl">
    $d=&format($c, '3s');
  <startouttext />
  <p>c is $c</p>
  <p>d is $d</p>
  <endouttext />

Gives outputs such as:

c is 198.696
d is 199

c is 444.144
d is 444

c is 58.44
d is 58.4

In what way is this failing to round properly, it seems correct to me?

Perhaps you can give me a specific number that you think it is dealing
with incorrectly?

guy@albertelli.com   0-7-2-5-15,728