help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fprintf, %e


From: Jakub Selesovsky
Subject: Re: fprintf, %e
Date: Thu, 31 Aug 2006 08:38:37 +0200
User-agent: Opera Mail/9.00 (Linux)

Thank you Tom,

I supposed it would be a problem of this kind. I have found another solution for both types (+/-) exponents. I will use the sed stream editor to replace the 'e+' or the 'e-' string by the 'e+0', resp. 'e-0' string in the octave output file. I wanted only to ask if it is possible to solve this problem directly in octave.

Jakub

On Wed, 30 Aug 2006 22:31:40 +0200, Tom Holroyd (NIH/NIMH) [E] <address@hidden> wrote:

The problem is with the underlying C library's conversion function, not Octave.
But you can do this (for positive exponents only):

        x = 1.2345678910e+002;
        ex = floor(log(x)/log(10));
        y = x / 10**ex;
        fprintf('%10.10f+%03d\n', y, ex)
        => 1.2345678910+002

Jakub Selesovsky wrote:
Hello,
I have a little problem with the fprintf function. For another processing I need to have the results from octave in this form:
 1.2345678910e+002
I am able to control the precision and the width of the column via '%17.10e' but I don't know how to control the number of digits behind letter 'e'. I am always getting the output with two digits (e+02) in exponent, but I have to get three digits (e+002).
 Than you for any help.
Jakub





--
Jakub Selesovsky
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]