DecimalFormat method in macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DecimalFormat method in macro

CARL Philippe (LBP)
Dear all,
Is there an easy way apply something similar to the Java DecimalFormat("#0.000") feature within a macro ?
I thank you very much in advance for your lighting on this.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: DecimalFormat method in macro

Wayne Rasband-2
> On Aug 16, 2020, at 2:31 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear all,
> Is there an easy way apply something similar to the Java DecimalFormat("#0.000") feature within a macro ?
> I thank you very much in advance for your lighting on this.
> My best regards,
> Philippe

The ImageJ 1.53d61 daily build adds a String.format() macro function, which is the same as the String.format() method in Java.

Here is an example:

  arr = newArray(23.59004,35.7,3.0,9, 0);
  for (i=0; i<arr.length; i++)
     print(String.format(“%.3f", arr[i]));

And here is the output:

   23.590
   35.700
   3.000
   9.000
   0.000

-wayne

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