comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Strange Bug with numeric double constants
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Strange Bug with numeric double constants [message #14700] Mon, 22 March 1999 00:00
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
Alex Schuster <alex@rosa.mpin-koeln.mpg.de> writes:

> Hi!

> I just experienced some weird IDL behaviour:

> IDL> help, 1.0d+2.0d

> help, 1.0d+2.0d
> ^
> % Syntax error.

> IDL> help, 1d+2d

> help, 1d+2d
> ^
> % Syntax error.

> Strange, isn't it? There's no problem with byte constants:

> IDL> help, 1b+2b
> <Expression> BYTE = 3

> An additional blank helps:

> IDL> help, 1d +2d
> <Expression> DOUBLE = 3.0000000

> I didn't try IDL 5.2, but it happened with 4.0 and 5.1 on Unix and
> Windows. I guess IDL expects an exponential notation like 1d0, and is
> confused by the nonnumeric plus character.



Wouldn't it be more proper to write these numbers as

IDL> help, 1.0d0+2.0d0

As others have pointed out, IDL is getting confused by putting the +2
immediately after the "d"--it thinks it's part of the exponent. I guess that
IDL usually knows what you meant if you leave the exponent off, but not always
as you found out.

Cheers,

William Thompson
Re: Strange Bug with numeric double constants [message #14702 is a reply to message #14700] Mon, 22 March 1999 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Alex Schuster wrote:
>
> Hi!
>
> I just experienced some weird IDL behaviour:
>
> IDL> help, 1.0d+2.0d
>
> help, 1.0d+2.0d
> ^
> % Syntax error.
> [...]


I'd just say it's normal. Since '+' or '-' are two allowed characters
in the exponential, IDL wants to interpret everything after '+' as the
exponent, and you are limited to integer exponents here.

Just for fun: if you try
help,1.d*2.d it will work!

Martin.

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
Re: Strange Bug with numeric double constants [message #14709 is a reply to message #14700] Mon, 22 March 1999 00:00 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Alex Schuster wrote:

> Hi!
>
> I just experienced some weird IDL behaviour:
>
> IDL> help, 1.0d+2.0d
>
> help, 1.0d+2.0d
> ^
> % Syntax error.
> IDL> help, 1d+2d
>
> help, 1d+2d
> ^
> % Syntax error.
>
> Strange, isn't it? There's no problem with byte constants:
>
> IDL> help, 1b+2b
> <Expression> BYTE = 3
>
> An additional blank helps:
>
> IDL> help, 1d +2d
> <Expression> DOUBLE = 3.0000000
>
> I didn't try IDL 5.2, but it happened with 4.0 and 5.1 on Unix and
> Windows. I guess IDL expects an exponential notation like 1d0, and is
> confused by the nonnumeric plus character.
>
> Alex
> --
> Alex Schuster Wonko@weird.cologne.de PGP Key available
> alex@pet.mpin-koeln.mpg.de

If you look to the exponent definition it isn't strange because
help, 1d+2
<Expression> DOUBLE = 100.00000

It isn't allowed to use the D to define double more than once in a
definiton of a number.

If you won't use blank to separate the numbers you can use ()

help, (1d)+(2d)
<Expression> DOUBLE = 3.0000000

R.Bauer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Colour maps ... (BYTE_SCALE)
Next Topic: Re: Passing a structured variable as an argument of procedure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:22:15 PDT 2025

Total time taken to generate the page: 0.00406 seconds