Fiji/ImageJ convert NaN to 0 parseFloat bug with arrays and tables

Hi,
I am using a Macro that gets the values from tables (results or a user-created table) and I need to replace NaNs with zero for the next step in the macro to work (Array.findMaxima), but every method I have tried for replacing NaNs runs into bugs. I have tried converting the table to arrays or new tables, but even if the ‘NaN’ gets replaced as a 0 and I use the parseFloat command to specify that the 0 is a number, it is still somehow not recognized as such; ie. the parseFloat command doesn’t seem to work for array or table elements (tho it does work for strings). Who should I ask to address this bug or does someone know any other ways to do this that actually work? (Please test first, as many things that should work don’t seem to.)

I found a work-around that seems to work on Windows 10 PCs. It converts each line of the results table to a string, replaces NaNs with 0 and then creates an array from the string. I feel like there should be a better way to do this.
for (row=0; row<nResults; row++) {
line = “”;
line = line + getResult(“Mean”,row);
meanNum=parseFloat(line);
if (line.contains(NaN)){
line=0;}
meanNum=parseFloat(line);
if (row== 0) {
meanNumArray=meanNum;}
if (row>0){
meanNumArray= Array.concat(meanNumArray, meanNum);}}
maxSlice=Array.findMaxima(meanNumArray, 0);

Thanks!

Does the following demo macro work for you?

a = newArray(1,2,NaN,NaN,5,NaN,7,8,NaN,10,11,12,NaN,14,NaN,16,NaN);
Array.show(a);
Table.create("Test");
Table.setColumn("Numbers", a);
i = Table.size;
while (i>0) {
   i--;
   if ( isNaN(Table.get("Numbers", i)) ) Table.set("Numbers", i, 0);
}

I am unable to reproduce this problem The following test macro works as expected. It creates a table with half the entries NaN and it then converts the NaN entries to zeros.

Table.create("Results");
for (col=0; col<4; col++) {
   for (row=0; row<8; row++) {
      if (row<4)
         Table.set("col"+col, row, row*(col+1));
      else
        Table.set("col"+col, row, NaN);
   }
}
for (col=0; col<4; col++) {
   for (row=0; row<8; row++) {
      if (isNaN(Table.get("col"+col, row)))
         Table.set("col"+col, row, 0);
    }
}