question about mixing numbers and strings without using d2s() or parseFloat() first

Posted by Cammer, Michael-3 on
URL: http://imagej.273.s1.nabble.com/question-about-mixing-numbers-and-strings-without-using-d2s-or-parseFloat-first-tp5023312.html

Would you please help me with a question about strings and numbers with operators?


I expected the following n= and n0= to give errors:


nstring = "" + "6.7635";
n = nstring + 17;
n0 = 17 + nstring;


However,

print(n);
print(n0);
yielded
6.763517
23.7635

Is this new in ImageJ that numbers and strings may be converted in expressions based on the type of the first element in an equation or have I simply not noticed it before?


Thank you!


Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory

NYU Langone Health, 540 First Avenue, SK2 Microscopy Suite, New York, NY  10016

[hidden email]<mailto:[hidden email]>  http://nyulmc.org/micros  http://microscopynotes.com/

Voice direct only, no text or messages:  1-914-309-3270 and 1-646-501-0567


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