<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Dear all,</p>
<p>May be the question is only about Java, or may be about how
Scilab implements it.</p>
<p>In order to do some tests to fix the regression brought by Scilab
6 and reported as the major <a moz-do-not-send="true"
href="http://bugzilla.scilab.org/16376">bug 16376</a> about how
datatips display (big or) small values (all displayed as 0 instead
of using an exponential notation), i am trying to use the <a
href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html">java.lang.String</a>
class and its <a moz-do-not-send="true"
href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)">.format()
method</a>, in Scilab language.<br>
</p>
<p>Indeed, the java.text.DecimalFormat class used for datatips has
no <i>self-adaptative format similar to the "%g" printf one</i>
(that automatically chooses the normal or exponential numerical
notation according to the magnitude of the absolute value to
display), while the String class provides this .format() method,
with <a moz-do-not-send="true"
href="https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax">all
printf formatting conventions</a>, including the "%g" one.<br>
<br>
Now, even about only the Java side, something is unclear to me:<br>
The official documentation of the String class presents .format()
as a String method, not as a String constructor. <br>
If so, then .format should be applied to a predefined String. But
which one? What is done with it? It could be the String format,
but this one is provided as an explicit input of the method...<br>
<br>
<font face="monospace">--> jimport java.lang.String<br>
--> s = String.new()<br>
s = <br>
<br>
--> s.length() // OK, this works<br>
ans =<br>
0<br>
<br>
--> s.format("%6.2f", -3.1415926)<br>
Undefined operation for the given operands.<br>
check or define function %eo_e for overloading.</font></p>
<p><font face="monospace">--> s = String.new("%6.1f")<br>
s = <br>
%6.1f<br>
</font></p>
<p><font face="monospace">--> s.format(-3.1415926)<br>
Undefined operation for the given operands.<br>
check or define function %eo_e for overloading.<br>
</font></p>
<p>Yet, the .format method is actually listed among all String's
methods:<br>
<font face="monospace">--> or(jgetmethods(String)=="format")<br>
ans =<br>
T</font><br>
</p>
<p>Using the java.text.DecimalFormat class to fix the bug will
anyway be possible, with explicit conditions on the magnitude of
the value to display. But i would like to understand this error
about String.format().<br>
<br>
Any hint is welcome.<br>
</p>
<p>Regards<br>
Samuel<br>
<br>
</p>
</body>
</html>