Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#593 total(lonarr) gives wrong answer

v1.0 (example)
closed-works-for-me
nobody
5
2014-04-25
2014-03-23
enrico
No

Using both gdl 0.9.2 and 0.9.4 on a VM with Ubuntu 12.04 guest and Windows7 host (both 64bit) I found:

1)

a=lonarr(3)
a=[8926507,8938828,0]
print,total(a),format='(i)'
17865336

which is wrong because: 8926507+8938828+0=17865335

2)

print,total(a)-1,format='(i)'
17865336

so i obtain total(a)=total(a)-1

3)

total(a) eq 17865335 returns TRUE (e.g. when put in a if-then statement)

BUT if I use two different numbers, the bug vanishes:

4)

a=lonarr(3)
a=[9469071,9272525,0]
print,total(a),format='(i)'
18741596

Finally, defining e.g. a=8926507 and b=8938828, a+b gives the correct result. Moreover, 17865336 eq 17865335 returns FALSE.

I'm quite new to GDL, but it seems to me a total- or lonarr-related bug.

For completeness: I've installed gdl 0.9.2 through apt-get, and gdl 0.9.4 compiling it with cmake, make, make check (all passed) and make install.

Discussion

  • Alain C.
    Alain C.
    2014-03-24

    • status: open --> closed-works-for-me
     
  • Alain C.
    Alain C.
    2014-03-24

    (IDL gives the same values ...)

    Without /preserve, TOTAL() internal computations are made in float.

    without format, the result (total(a)) is : 1.78653e+07 which would have inform you of potential problems ...

    You can replay with TOTAL( ,/preserve) and re-open a bug report
    if other issues found.

    Alain