Trouble getting values from custom table

I am having trouble with retrieving numerical values from a custom table in a macro. A similar process worked fine when using the default results table, so I may be doing something wrong
This seems to be the problematic bit:

a = Table.get("FWHM (px)", 1);
b = Table.get("FWHM (px)", 0);
c = ( a / b) ;

(although the actual line in my macro is

Math.abs( (Table.get("FWHM (px)", 1) / Table.get("FWHM (px)", 0) ) -1 );

This is the debug window
debug

From the debug window it seems that the results are being retrieved as strings, but my understanding was that Table.get retrieved values, and they are added to the table (using Table.set) as values.
Thanks for any assistance

Edit: I should add that this is ImageJ 1.53d, and to expand on the above, I am able to completely reproduce the problem with the following:

Table.create("Example table");
Table.set("FWHM (px)", 0, 4.810259780896215);
Table.set("FWHM (px)", 1, 4.883674541363164);
Table.update;

a = Table.get("FWHM (px)", 1);
b = Table.get("FWHM (px)", 0);
c = ( a / b) ;
print(c);

I don’t know if this supports my above idea, but if I run Math.abs on a and b I am able to do arithmetic on them as normal

Hello Ben -

I can reproduce your issue.

It appears to me that Table.set() is setting the values as strings.
Or, at least in any event, Table.get() is returning them as strings.

Here is my version:

print (IJ.getFullVersion);           // check version
Table.create ("my table");           // one-cell table
Table.set ("col0", 0, 1.01000);      // sets cell with string?
t00s = Table.getString ("col0", 0);  // retrieve as string
print (t00s, t00s + 7);              // makes sense
t00 = Table.get ("col0", 0);         // retrieve as number
print (t00, t00 + 7);                // oops, got string
t00v = 0.0 + t00;                    // coerce to value
print (t00v, t00v + 7);              // works!

Here is the Log window output:

1.53b05
1.0100 1.01007
1.01 1.017
1.01 8.01

Note the trailing "0"s in “1.0100”. That’s why I speculate that the
values are actually getting set as strings.

The work-around seems to be, as you did, to coerce the strings
to numerical values. In my example, I did this by adding them
to 0.0.

Thanks, mm

Hi, thank you for that, I’m glad to see it wasn’t just me.
Changing to

Table.create("Example table");
Table.set("FWHM (px)", 0, 4.810259780896215);
Table.set("FWHM (px)", 1, 4.883674541363164);
Table.update;

a = Table.get("FWHM (px)", 1);
b = Table.get("FWHM (px)", 0);
d=0.0 + a;
e=0.0 +b;
c = ( d / e) ;
print(c);

as you suggested does work, though I note it doesn’t if the order is switched (i.e. d=a+0.0).

Adding zero is a better workaround though, thanks, I couldn’t think what else would persuade it!

The ImageJ 1.53e2 daily build fixes a bug that caused Table.get() to return a string instead of a number.

Hello Wayne -

I can confirm that my example macro runs as expected after
updating to 1.53e2. Here is my updated Log output:

1.53e02
1.0100 1.01007
1.01 8.01
1.01 8.01

Thanks, mm

Thank you, can confirm it works for me too