Re: Recognizing double precision? [message #56145] |
Sat, 06 October 2007 15:21  |
Bringfried Stecklum
Messages: 75 Registered: January 1996
|
Member |
|
|
wlandsman wrote:
> About once a year I receive a complaint about my code because someone
> inputs a Julian date like this
>
> IDL> jd = 2441636.1
>
> and then gets mysterious results because the value of jd is
> "truncated"
>
> IDL> print, jd, f='(f10.2)'
> 2441636.00
>
> So it would it be reasonable to request that the IDL compiler
> recognize a number as double precision, if it has too many digits to
> be stored as a floating point number? After all, IDL does do
> something like this (in default mode) for short and long integers:
>
> IDL> a = 32767 & help,a
> A INT = 32767
> IDL> a = 32768 & help,a
> A LONG = 32768
>
> I can't imagine how adding this capability would break existing code.
>
> Does anyone know if other interpreted languages can recognize a double
> precision number when they encounter one? Thanks, --Wayne
>
Dear Wayne,
although I think that in principle the compiler could be able to make an
automatic type declaration based on the number of digits of the string
representing the numerical value, for the time being it might be easier
to check whether the input is indeed double precision or not. For
instance, I noticed that an earlier version of DAYCONV had the following
line at the beginning
sz = size(xjd)
However the information on the size of the argument xjd was never used.
Perhaps somebody had in mind the following?
if sz[1] ne 5 then message,'DAYCONV requires double precision!'
It would be hard to overlook a statement like this.
with kind regards,
Bringfried Stecklum
|
|
|