Posted by
Joachim Wesner on
Sep 11, 2009; 10:19am
URL: http://imagej.273.s1.nabble.com/IJ-d2s-quirk-tp3691174p3691178.html
Hi Wayne,
yes I see that point, but IMHO there should be a way to suppress switching
to exponential if requested, to avoid that LARGER values come out in
SMALLER (zero) results.
Also,
1) The number of digits right to the decimal point in exponential form
should be the same as in the non-exp form!? (It´s always 3)
2) When the switch occurs should somehow depend in a sensible way on the #
of digits given.
I checked the sourcecode, there is this undocumented(?) feature that giving
a *negative* number of digits, solves 1) above, but 2) would need a change.
Most sincerely
Joachim Wesner
Wayne Rasband
<
[hidden email]>
Gesendet von: An
ImageJ Interest
[hidden email]
Group Kopie
<
[hidden email].
GOV> Thema
Re: IJ.d2s "quirk"
10.09.2009 17:36
Bitte antworten
an
ImageJ Interest
Group
<
[hidden email].
GOV>
> Hi again,
> I already note for some time, that IJ.ds2 has a "quirk"
> for very small values, for example
> double small_value = 9.915e-6;
> IJ.write(IJ.d2s (small_value, 2));
> will not output
> "0.00"
> but
> "9.915E-6"
> instead!
> Is this intended behaviour?
IJ.d2s() automatically switches to scientific notation for very small
values to prevent them from being misleadingly displayed in the Results
table as zero. You can avoid the use of scientific notation by
increasing the number of decimal places. Here is what you get
0 9.915E-6
1 9.915E-6
2 9.915E-6
3 9.915E-6
4 9.915E-6
5 9.915E-6
6 0.000010
7 0.0000099
8 0.00000992
9 0.000009915
when you run this macro
n = 9.915e-6;
for (d=0; d<=9; d++)
print(d2s(n,d));
-wayne
> Sometimes it might be useful to tell if a result is not exactly zero,
but
> *LARGER* numbers will nevertheless be rounded down to zero as for ex.
1e-3!
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________