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

Home » Public Forums » archive » Inaccuracies
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Inaccuracies [message #5313] Mon, 13 November 1995 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
Ok, I am sure this has been discussed before, but let
me start this thread again. I wish to create a 15-element
vector which contains the numbers -1.4 to 1.4 by an increment
of 0.2 I also wish the sum of these elements to be zero
(No, this isn't the new math). Here is what I tried...


TRIAL #1
========
IDL> a = findgen(15)*.2 - 1.4
IDL> print, total(a)
7.15256e-07

Hmmm! Not so good.


TRIAL #2
========
IDL> a = dindgen(15)*(.2D)-1.4D
IDL> print, total(a, /double)
4.4408921e-15

Ok, this is better but not correct.
And what are the values of a?

IDL> print, a
-1.4000000 -1.2000000 -1.0000000 -0.80000000
-0.60000000 -0.40000000 -0.20000000 2.2204460e-16
0.20000000 0.40000000 0.60000000 0.80000000
1.0000000 1.2000000 1.4000000

I seem to have lost a zero somewhere, and for me this matters!!!



TRIAL #3
========
What if I only needed 13 numbers between -1.2 and 1.2.
IDL> a = findgen(13)*.2 - 1.2
IDL> print, total(a)
0.00000

Now how can I get this to work for 15 numbers?

Maybe I am missing something here, but this kind of behavior
makes IDL a bit problematical for scientific use. With only 15
numbers and double precision arithmetic, I can't believe this
would fail in FORTRAN or C!

--
Andrew F. Loughe (afl@cdc.noaa.gov)
University of Colorado, CIRES * Campus Box 449 * Boulder, CO 80309
phone: (303) 492-0707 fax: (303) 497-7013
[Message index]
 
Read Message
Read Message
Previous Topic: [Request] Plotting procedure for wind-rose
Next Topic: Tracing objects (video input)

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

Current Time: Fri Oct 10 07:07:28 PDT 2025

Total time taken to generate the page: 0.63988 seconds