gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

shmmap variable does not hold the value given to it #1726

Closed brandy125 closed 7 months ago

brandy125 commented 8 months ago

Can anybody explain this?

GDL> shmmap,'test',/double,1
GDL> tmp=shmvar('test')
GDL> tmp(0)=double(156275001)
GDL> print,tmp,f='(D20.5)'
     156275008.00000
GillesDuvert commented 8 months ago

@brandy125 indeed this is pretty strange, and I have the same issue.

alaingdl commented 8 months ago

@GillesDuvert as I mentionned in #1715 the types in SHMMAP are not OK. Eg :

IDL> shmmap,'test',/ulong, 1
IDL> tmp=shmvar('test')
IDL> help, tmp
TMP             ULONG     = SharedMemory<TEST> Array[1]

[...]
GDL> shmmap,'test',/ulong, 1
GDL> tmp=shmvar('test')
GDL> help, tmp
TMP             FLOAT     = SharedMemory<test> Array[1]

If you try to put a too long number into a float, you don't know what may happen. Eg :

GDL> x=156275001.  ; please note the "." : a float
GDL> help, x
X               FLOAT     =   1.56275e+08
GDL> print, x
  1.56275e+08

GDL> print, long(x)
   156275008

Then for me, it is not a surprise, we have to fix the definition of type in SHMMAP (and we all have had this problem somewhere in a code : the sky is falling)

GillesDuvert commented 8 months ago

@alaingdl you're right this is most probaby a duplicate of #1715.

GillesDuvert commented 7 months ago

should work with #1736