Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange output numbers, 5.7D-08

1,665 views
Skip to first unread message

Helmut Sennewald

unread,
Aug 5, 2006, 2:53:57 PM8/5/06
to
Hello,

How can I force Scilab 4.0 to output E or e instead D for
floating point numbers? Most(every) other program only understands
E or e for floating point numbers.

-->format('e',5),xopt
xopt =
5.7D-08 7.5D+00 5.0D-08 1.1D+00 1.3D-08

Best regards,
Helmut


Jean-Claude Arbaut

unread,
Aug 6, 2006, 3:42:17 AM8/6/06
to
Helmut Sennewald a écrit :

Try this:

write(%io(2),1.23e-8,'(e10.3)')

or

printf("%g",1.23e-8)

Helmut Sennewald

unread,
Aug 6, 2006, 4:30:05 AM8/6/06
to


Hello Jean-Claude,
thanks for showing me these commands.
I have found in the mean time one more function, mprintf.

-->mprintf("%10.3e",1.23e-8)
1.230e-008

I have now three possible workarounds, but I still wonder
why normal output is in D-Format, e.g. 3.456D-09.

Do you know who decided to use the 'D' for exponent instead of 'e'?
I can't believe that the compiler GCC has poduced this 'useless'
D for exponent. What's your opinion regarding this matter?

Best regards,
Helmut

PS: I recommend to change Scilab to output 'e' for exponent
instead of 'D'.

Jean-Claude Arbaut

unread,
Aug 6, 2006, 7:36:10 AM8/6/06
to
Helmut Sennewald a écrit :

> Hello Jean-Claude,
> thanks for showing me these commands.
> I have found in the mean time one more function, mprintf.
>
> -->mprintf("%10.3e",1.23e-8)
> 1.230e-008
>
> I have now three possible workarounds, but I still wonder
> why normal output is in D-Format, e.g. 3.456D-09.
>
> Do you know who decided to use the 'D' for exponent instead of 'e'?
> I can't believe that the compiler GCC has poduced this 'useless'
> D for exponent. What's your opinion regarding this matter?

It probably comes from Fortran notation for double precision numbers:
1e-8 is a REAL constant (4 bytes IEEE 754 format)
1d-8 is a DOUBLE PRECISION or REAL*8 constant (8 bytes IEEE 754)
By the way, it's easy to make the mistake in a Fortran program:
when x is a REAL*8, then you shouldn't write x=0.1 but x=0.1d0 !
But I don't know if Scilab can use single precision numbers.

> Best regards,
> Helmut
>
> PS: I recommend to change Scilab to output 'e' for exponent
> instead of 'D'.

I agree with you :-)

Helmut Sennewald

unread,
Aug 6, 2006, 8:53:35 AM8/6/06
to
"Jean-Claude Arbaut" <jcar...@laposte.net> schrieb im Newsbeitrag
news:44d5d3ee$0$1031$ba4a...@news.orange.fr...

> Helmut Sennewald a écrit :
>
> > Hello Jean-Claude,
> > thanks for showing me these commands.
> > I have found in the mean time one more function, mprintf.
> >
> > -->mprintf("%10.3e",1.23e-8)
> > 1.230e-008
> >
> > I have now three possible workarounds, but I still wonder
> > why normal output is in D-Format, e.g. 3.456D-09.
> >
> > Do you know who decided to use the 'D' for exponent instead of 'e'?
> > I can't believe that the compiler GCC has poduced this 'useless'
> > D for exponent. What's your opinion regarding this matter?
>
> It probably comes from Fortran notation for double precision numbers:
> 1e-8 is a REAL constant (4 bytes IEEE 754 format)
> 1d-8 is a DOUBLE PRECISION or REAL*8 constant (8 bytes IEEE 754)
> By the way, it's easy to make the mistake in a Fortran program:
> when x is a REAL*8, then you shouldn't write x=0.1 but x=0.1d0 !
> But I don't know if Scilab can use single precision numbers.


Hello Jean Claude,

Thanks for the background information.
It's by far not my intention to use single precision floating point.
My wish is that the default output in Scilab is printing the exponent
with the 'e'-character and not with the D-characater.
Is their any simple way to compile Scilab to get this fixed?

As it is:
-->x
x =
1.230D-09

As it should be:
-->x
x =
1.230e-09

Best regards,
Helmut

Stimpson

unread,
Aug 8, 2006, 2:27:49 AM8/8/06
to
Hello Helmut.

This is indeed kinda disturbing. I got the same erroneous display of
'D' instead of 'e'.
However, this only occurs when I try to use the format() function. It
may be broken.
When i use the function that Jean-Claude mentioned above
fprintf(%io(2),'number = %1.3e', x); it shows the e correctly.

Regards,

Martin

0 new messages