Thank Richard.

So far, I just punted. My site runs on a dedicated box and doesn't 
have to service a lot of users so I just wrote a one line C program 
to print a single value using a specified format (default is %.4e) 
and use exec() to call it.

    printe [format] value

Here's how I encapsulated it:

function printe( $x )
     $lines = array();
     exec( "/usr/local/bin/printe \"".$x."\"", $lines );
     return $lines[0];

and an example of how I call the function:

     fputs( $fp, sprintf( "%8.2f %s %s\n", $this->O_a_time[$i],
         printe($this->O_a_cooling[$i]) ) );

It works well enough for now. Eventually I hope to have time to play 
and then I'll come back and figure out a real patch for PHP's printf 
to support %e directly.


At 12:09 AM -0500 10/5/01, Richard Lynch wrote:
>You could roll your own...
>% and (int) / and round() are all you need.
>----- Original Message -----
>From: Bill Rausch <[EMAIL PROTECTED]>
>Subject: printf scientific notation?
>  > Can PHP print floating point numbers using scientific notation?
>>  (like 1.32e+5) sscanf reads them ok using %f, but I'd like to print
>>  them with %e or %g and the printf documentation doesn't mention them.
>  > I've tried %e anyway and it fails to print the exponent part.

  Bill Rausch, Software Development, Unix, Mac, Windows
  Numerical Applications, Inc.  509-943-0861   [EMAIL PROTECTED]

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to