Re: printing with a format in exponent! [message #77995] |
Mon, 10 October 2011 21:06 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On 10/10/11 4:07 PM, Paulo Penteado wrote:
>
> http://www.idlcoyote.com/math_tips/sky_is_falling.html
>
>
> On Oct 10, 4:26 pm, Kim<adisn...@hotmail.com> wrote:
>> I'm quite confused why the formation option does not print as it
>> should.
>>
>> In the IDL terminal, I simply typed the following
>>
>> IDL> print, 1.58058980019603E+07, format='(E20.14)'
>>
>> However, it prints
>>
>> IDL> 1.580589800000E+07
>>
>> It is really important for the format to work because my calculation
>> goes up to 12th decimal point.
>>
>> Does anyone know why this is and how I can fix this problem?
To elaborate slightly, you'll need to be using double precision if you
need to be precise to the 12th decimal point:
IDL> print, 1.58058980019603e7, format='(E20.14)'
1.58058980000000E+07
IDL> print, 1.58058980019603d7, format='(E20.14)'
1.58058980019603E+07
Although be careful... just because you are using doubles, your
calculation may not preserve the maximum degree of machine precision.
-Jeremy.
|
|
|
Re: printing with a format in exponent! [message #78002 is a reply to message #77995] |
Mon, 10 October 2011 13:07  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
http://www.idlcoyote.com/math_tips/sky_is_falling.html
On Oct 10, 4:26 pm, Kim <adisn...@hotmail.com> wrote:
> I'm quite confused why the formation option does not print as it
> should.
>
> In the IDL terminal, I simply typed the following
>
> IDL> print, 1.58058980019603E+07, format='(E20.14)'
>
> However, it prints
>
> IDL> 1.580589800000E+07
>
> It is really important for the format to work because my calculation
> goes up to 12th decimal point.
>
> Does anyone know why this is and how I can fix this problem?
|
|
|