Force to print exponential to e-6 [message #88045] |
Fri, 14 March 2014 06:19  |
aberte@gmail.com
Messages: 8 Registered: December 2006
|
Junior Member |
|
|
I have, say an array with three numbers:
[2e-5,2e-6,2e-7]
I would like to print them on screen like this
20.0e-6, 2.0e-6, 0.2e-6
so forcing the exponential to be -6.
I can't figure it out how to do it. I'm trying to use string(format='(e)', x) without success.
Thanks
|
|
|
Re: Force to print exponential to e-6 [message #88046 is a reply to message #88045] |
Fri, 14 March 2014 06:30   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Doppler writes:
> I have, say an array with three numbers:
> [2e-5,2e-6,2e-7]
>
> I would like to print them on screen like this
> 20.0e-6, 2.0e-6, 0.2e-6
>
> so forcing the exponential to be -6.
>
> I can't figure it out how to do it. I'm trying to use string(format='(e)', x) without success.
I think you will probably have to write some kind of tick formatting
function:
http://www.idlcoyote.com/tips/exponents.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Force to print exponential to e-6 [message #88047 is a reply to message #88045] |
Fri, 14 March 2014 06:41  |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
On Friday, 14 March 2014 14:19:55 UTC+1, Doppler wrote:
> I have, say an array with three numbers:
>
> [2e-5,2e-6,2e-7]
>
>
>
> I would like to print them on screen like this
>
> 20.0e-6, 2.0e-6, 0.2e-6
>
>
>
> so forcing the exponential to be -6.
>
>
>
> I can't figure it out how to do it. I'm trying to use string(format='(e)', x) without success.
>
>
>
> Thanks
Here is one (ugly and nongeneral) way to do it:
IDL> a = [2e-5,2e-6,2e-7]
IDL> print, a*1e6, format='(3(f0.1, "e-6, "))'
20.0e-6, 2.0e-6, 0.2e-6
--
Yngvar
|
|
|