Login  Register

Re: Setting values to NaN with a macro

Posted by Adrian Daerr-2 on Nov 06, 2015; 5:36pm
URL: http://imagej.273.s1.nabble.com/Setting-values-to-NaN-with-a-macro-tp5014841p5014881.html

On 11/06/2015 10:40 AM, james_minto wrote:
>> In versions 1.44p and earlier, I could set zero values as NaN (not a
>> number) with the following macro:
>>
>> if(v==0)v=NaN;
>
> The change in NaN behavior occurs between ImageJ version 1.50a and 1.50d (I
> haven't yet tried the intermediate versions to find out exactly where) and
> also with java versions 1.6, 1.7 and OpenJDK8.

I can reduce the regression interval by one step: 1.50b could also set
pixels of 32bit images to NaN, but now that I upgraded to 1.50d I also
observe the bug. Note that a similar change holds for infinity:

             1.50d    1.50b and 1.49v (at least)
v=0.0/0.0   0        NaN
v=1.0/0.0   2^31-1   Infinity
v=-1.0/0.0  -2^31    -Infinity

It looks as if there was an integer conversion somewhere in the process,
that would map Float.POSITIVE_INFINITY to Integer.MAX_VALUE and so forth.

Adrian

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html