findgen anomaly? [message #67316] |
Fri, 10 July 2009 14:41 |
Chris Chronopoulos
Messages: 4 Registered: July 2009
|
Junior Member |
|
|
hi -
this morning i decided to write up a short function that would return
a list of values given a min, max and increment (like Mathematica's
Range[] function) but it was giving me some problems. i narrowed it
down to an oddity in findgen, which can described by the following
example:
IDL> min=5.5
IDL> max=6.2
IDL> increment=0.1
IDL> print, (max-min)/increment+1
8.00000
IDL> print,findgen(8.00000)
0.00000 1.00000 2.00000 3.00000 4.00000
5.00000
6.00000 7.00000
IDL> print, findgen((max-min)/increment+1)
0.00000 1.00000 2.00000 3.00000 4.00000
5.00000
6.00000
now, by any reasonable system of logic, shouldn't the last two lines
produce the same result? the correct result, of course, is the first
on that goes all the way up to 7.00000. the weird thing is that if you
change max from 6.2 to 6.3, it works fine. it seems there are certain
values that give it problems, while others work fine.
what is going on here?
|
|
|