[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fprintf, %e
From: |
Carlo de Falco |
Subject: |
Re: fprintf, %e |
Date: |
Thu, 31 Aug 2006 11:22:57 +0200 |
On 8/31/06, Jakub Selesovsky <address@hidden> wrote:
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.
yes you can,
for positive exponents:
a = rand(1)*1e+17;
printf(strrep(sprintf("%17.10e\n",a),"e+","e+0"));
3.1510983680e+016
for any exponent:
a = rand(1)*1e-17;
printf(strrep(strrep(sprintf("%17.10e\n",a),"e+","e+0"),"e-","e-0"));
8.6196674060e-19
Carlo