001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package jsx.core;
021 
022 import js.*;
023 
024 /**
025  * <p>A utility class providing basic number operations with its static methods.</p>
026  * <p>Users are encouraged to use the utilities provided by this class instead of the 
027  * <b>opaque</b> methods of {@link js.NumberLike}, {@link js.core.JsNumber} or 
028  * {@link js.Value.Number} in consideration of the reuse benefit for re-compilation 
029  * results.</p>
030  * 
031  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
032  */
033 public final class NumberLikes extends Disposable
034 {
035     private NumberLikes() {}
036 
037     /**
038      * <p>Converts the current number to a string using exponential notation.</p>
039      * @param n The current number.
040      * @return A string representation of the current number, in exponential notation. The 
041      * fractional part of the number is rounded, or padded with zeros, as necessary, so that 
042      * it has the specified length.
043      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
044      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
045      * {@link js.core.JsTypeError} for JS Simulation.
046      * @see #toExponential(js.NumberLike, Object)
047      * @see #toFixed(js.NumberLike)
048      * @see #toFixed(js.NumberLike, Object)
049      * @see #toLocaleString(js.NumberLike)
050      * @see #toPrecision(js.NumberLike)
051      * @see #toPrecision(js.NumberLike, Object)
052      * @see #toString(js.NumberLike)
053      * @see #toString(js.NumberLike, Object)
054      * @see js.NumberLike#toExponential()
055      * @since 1.0
056      */
057     public static final String toExponential(NumberLike<?> n) {
058         return n.toExponential();
059     }
060     /**
061      * <p>Converts the current number to a string using exponential notation.</p>
062      * @param n The current number.
063      * @return A string representation of the current number, in exponential notation. The 
064      * fractional part of the number is rounded, or padded with zeros, as necessary, so that 
065      * it has the specified length.
066      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
067      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
068      * {@link js.core.JsTypeError} for JS Simulation.
069      * @see #toExponential(Number, Object)
070      * @see #toFixed(Number)
071      * @see #toFixed(Number, Object)
072      * @see #toLocaleString(Number)
073      * @see #toPrecision(Number)
074      * @see #toPrecision(Number, Object)
075      * @see #toString(Number)
076      * @see #toString(Number, Object)
077      * @see js.Value.Number#toExponential()
078      * @since 1.0
079      */
080     public static final String toExponential(Number n) {
081         return new Value.Number(n).toExponential();
082     }
083     /**
084      * <p>Converts the current number to a string using exponential notation with the 
085      * specified number of digits after the decimal place.</p>
086      * @param n The current number.
087      * @param digits The number of digits that appears after the decimal point. This may be a 
088      * value between 0 and 20, inclusive, and implementations may optionally support a larger 
089      * range of values. If this argument is undefined, as many digits as necessary are used.
090      * @return A string representation of the current number, in exponential notation, 
091      * with one digit before the decimal place and <tt>digits</tt> digits after the 
092      * decimal place. The fractional part of the number is rounded, or padded with zeros, 
093      * as necessary, so that it has the specified length.
094      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
095      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
096      * {@link js.core.JsRangeError} for JS Simulation. Values between 0 and 20, inclusive, 
097      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
098      * larger and smaller values as well.
099      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
100      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
101      * {@link js.core.JsTypeError} for JS Simulation.
102      * @see #toExponential(js.NumberLike)
103      * @see #toFixed(js.NumberLike)
104      * @see #toFixed(js.NumberLike, Object)
105      * @see #toLocaleString(js.NumberLike)
106      * @see #toPrecision(js.NumberLike)
107      * @see #toPrecision(js.NumberLike, Object)
108      * @see #toString(js.NumberLike)
109      * @see #toString(js.NumberLike, Object)
110      * @see js.NumberLike#toExponential(Object)
111      * @since 1.0
112      */
113     public static final String toExponential(NumberLike<?> n, Object digits) {
114         return n.toExponential(digits);
115     }
116     /**
117      * <p>Converts the current number to a string using exponential notation with the 
118      * specified number of digits after the decimal place.</p>
119      * @param n The current number.
120      * @param digits The number of digits that appears after the decimal point. This may be a 
121      * value between 0 and 20, inclusive, and implementations may optionally support a larger 
122      * range of values. If this argument is undefined, as many digits as necessary are used.
123      * @return A string representation of the current number, in exponential notation, 
124      * with one digit before the decimal place and <tt>digits</tt> digits after the 
125      * decimal place. The fractional part of the number is rounded, or padded with zeros, 
126      * as necessary, so that it has the specified length.
127      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
128      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
129      * {@link js.core.JsRangeError} for JS Simulation. Values between 0 and 20, inclusive, 
130      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
131      * larger and smaller values as well.
132      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
133      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
134      * {@link js.core.JsTypeError} for JS Simulation.
135      * @see #toExponential(Number)
136      * @see #toFixed(Number)
137      * @see #toFixed(Number, Object)
138      * @see #toLocaleString(Number)
139      * @see #toPrecision(Number)
140      * @see #toPrecision(Number, Object)
141      * @see #toString(Number)
142      * @see #toString(Number, Object)
143      * @see js.Value.Number#toExponential(Object)
144      * @since 1.0
145      */
146     public static final String toExponential(Number n, Object digits) {
147         return new Value.Number(n).toExponential(digits);
148     }
149     /**
150      * <p>Converts the current number to a string without digits after the decimal place.</p>
151      * @param n The current number.
152      * @return A string representation of the current number that does not use exponential 
153      * notation and has no digits after the decimal place. The number is rounded if 
154      * necessary. If the current number is greater than 1e+21, this method simply calls 
155      * {@link js.DateLike#toString()} and returns a string in exponential notation.
156      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
157      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
158      * {@link js.core.JsTypeError} for JS Simulation.
159      * @see #toFixed(js.NumberLike, Object)
160      * @see #toExponential(js.NumberLike)
161      * @see #toExponential(js.NumberLike, Object)
162      * @see #toLocaleString(js.NumberLike)
163      * @see #toPrecision(js.NumberLike)
164      * @see #toPrecision(js.NumberLike, Object)
165      * @see #toString(js.NumberLike)
166      * @see #toString(js.NumberLike, Object)
167      * @see js.NumberLike#toFixed()
168      * @since 1.0
169      */
170     public static final String toFixed(NumberLike<?> n) {
171         return n.toFixed();
172     }
173     /**
174      * <p>Converts the current number to a string without digits after the decimal place.</p>
175      * @param n The current number.
176      * @return A string representation of the current number that does not use exponential 
177      * notation and has no digits after the decimal place. The number is rounded if 
178      * necessary. If the current number is greater than 1e+21, this method simply calls 
179      * {@link js.DateLike#toString()} and returns a string in exponential notation.
180      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
181      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
182      * {@link js.core.JsTypeError} for JS Simulation.
183      * @see #toFixed(Number, Object)
184      * @see #toExponential(Number)
185      * @see #toExponential(Number, Object)
186      * @see #toLocaleString(Number)
187      * @see #toPrecision(Number)
188      * @see #toPrecision(Number, Object)
189      * @see #toString(Number)
190      * @see #toString(Number, Object)
191      * @see js.Value.Number#toFixed()
192      * @since 1.0
193      */
194     public static final String toFixed(Number n) {
195         return new Value.Number(n).toFixed();
196     }
197     /**
198      * <p>Converts the current number to a string that contains a specified number of 
199      * digits after the decimal place.</p>
200      * @param n The current number.
201      * @param digits The number of digits to appear after the decimal point; this may be a 
202      * value between 0 and 20, inclusive, and implementations may optionally support a 
203      * larger range of values. If this argument is undefined, it is treated as 0.
204      * @return A string representation of the current number that does not use exponential 
205      * notation and has exactly <tt>digits</tt> digits after the decimal place. The number 
206      * is rounded if necessary, and the fractional part is padded with zeros if necessary so 
207      * that it has the specified length. If the current number is greater than 1e+21, this 
208      * method simply calls {@link js.NumberLike#toString()} and returns a string in exponential 
209      * notation.
210      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
211      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
212      * {@link js.core.JsRangeError} for JS Simulation. Values between 0 and 20, inclusive, 
213      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
214      * larger and smaller values as well.
215      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
216      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
217      * {@link js.core.JsTypeError} for JS Simulation.
218      * @see #toFixed(js.NumberLike)
219      * @see #toExponential(js.NumberLike)
220      * @see #toExponential(js.NumberLike, Object)
221      * @see #toLocaleString(js.NumberLike)
222      * @see #toPrecision(js.NumberLike)
223      * @see #toPrecision(js.NumberLike, Object)
224      * @see #toString(js.NumberLike)
225      * @see #toString(js.NumberLike, Object)
226      * @see js.NumberLike#toFixed(Object)
227      * @since 1.0
228      */
229     public static final String toFixed(NumberLike<?> n, Object digits) {
230         return n.toFixed(digits);
231     }
232     /**
233      * <p>Converts the current number to a string that contains a specified number of 
234      * digits after the decimal place.</p>
235      * @param n The current number.
236      * @param digits The number of digits to appear after the decimal point; this may be a 
237      * value between 0 and 20, inclusive, and implementations may optionally support a 
238      * larger range of values. If this argument is undefined, it is treated as 0.
239      * @return A string representation of the current number that does not use exponential 
240      * notation and has exactly <tt>digits</tt> digits after the decimal place. The number 
241      * is rounded if necessary, and the fractional part is padded with zeros if necessary so 
242      * that it has the specified length. If the current number is greater than 1e+21, this 
243      * method simply calls {@link js.NumberLike#toString()} and returns a string in exponential 
244      * notation.
245      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
246      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
247      * {@link js.core.JsRangeError} for JS Simulation. Values between 0 and 20, inclusive, 
248      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
249      * larger and smaller values as well.
250      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
251      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
252      * {@link js.core.JsTypeError} for JS Simulation.
253      * @see #toFixed(Number)
254      * @see #toExponential(Number)
255      * @see #toExponential(Number, Object)
256      * @see #toLocaleString(Number)
257      * @see #toPrecision(Number)
258      * @see #toPrecision(Number, Object)
259      * @see #toString(Number)
260      * @see #toString(Number, Object)
261      * @see js.Value.Number#toFixed(Object)
262      * @since 1.0
263      */
264     public static final String toFixed(Number n, Object digits) {
265         return new Value.Number(n).toFixed(digits);
266     }
267     /**
268      * <p>Converts the current number to a string.</p>
269      * <p>This method simply calls {@link js.NumberLike#toString()} to convert the number to a base-10 
270      * value.</p>
271      * @param n The current number.
272      * @return A string representation of the current number. The number is rounded or 
273      * padded with zeros as necessary.
274      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
275      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
276      * {@link js.core.JsTypeError} for JS Simulation.
277      * @see #toPrecision(js.NumberLike, Object)
278      * @see #toExponential(js.NumberLike)
279      * @see #toExponential(js.NumberLike, Object)
280      * @see #toFixed(js.NumberLike)
281      * @see #toFixed(js.NumberLike, Object)
282      * @see #toLocaleString(js.NumberLike)
283      * @see #toString(js.NumberLike)
284      * @see #toString(js.NumberLike, Object)
285      * @see js.NumberLike#toPrecision()
286      * @since 1.0
287      */
288     public static final String toPrecision(NumberLike<?> n) {
289         return n.toPrecision();
290     }
291     /**
292      * <p>Converts the current number to a string.</p>
293      * <p>This method simply calls {@link js.NumberLike#toString()} to convert the number to a base-10 
294      * value.</p>
295      * @param n The current number.
296      * @return A string representation of the current number. The number is rounded or 
297      * padded with zeros as necessary.
298      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
299      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
300      * {@link js.core.JsTypeError} for JS Simulation.
301      * @see #toPrecision(Number, Object)
302      * @see #toExponential(Number)
303      * @see #toExponential(Number, Object)
304      * @see #toFixed(Number)
305      * @see #toFixed(Number, Object)
306      * @see #toLocaleString(Number)
307      * @see #toString(Number)
308      * @see #toString(Number, Object)
309      * @see js.Value.Number#toPrecision()
310      * @since 1.0
311      */
312     public static final String toPrecision(Number n) {
313         return new Value.Number(n).toPrecision();
314     }
315     /**
316      * <p>Converts the current number to a string using the specified number of significant 
317      * digits. Uses exponential or fixed-point notation depending on the size of the number 
318      * and the number of significant digits specified.</p>
319      * @param n The current number.
320      * @param precision The number of significant digits to appear in the returned string. 
321      * This may be a value between 1 and 21, inclusive. Implementations are allowed to 
322      * optionally support larger and smaller values of precision. If this argument is 
323      * undefined, the {@link #toString()} method is used instead to convert the number to 
324      * a base-10 value.
325      * @return A string representation of the current number that contains 
326      * <tt>precision</tt> significant digits. If <tt>precision</tt> is large 
327      * enough to include all the digits of the integer part of the number, the returned 
328      * string uses fixed-point notation. Otherwise, exponential notation is used with one 
329      * digit before the decimal place and <tt>precision - 1</tt> digits after the 
330      * decimal place. The number is rounded or padded with zeros as necessary.
331      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
332      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
333      * {@link js.core.JsRangeError} for JS Simulation. Values between 1 and 20, inclusive, 
334      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
335      * larger and smaller values as well.
336      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
337      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
338      * {@link js.core.JsTypeError} for JS Simulation.
339      * @see #toPrecision(js.NumberLike)
340      * @see #toExponential(js.NumberLike)
341      * @see #toExponential(js.NumberLike, Object)
342      * @see #toFixed(js.NumberLike)
343      * @see #toFixed(js.NumberLike, Object)
344      * @see #toLocaleString(js.NumberLike)
345      * @see #toString(js.NumberLike)
346      * @see #toString(js.NumberLike, Object)
347      * @see js.NumberLike#toPrecision(Object)
348      * @since 1.0
349      */
350     public static final String toPrecision(NumberLike<?> n, Object precision) {
351         return n.toPrecision(precision);
352     }
353     /**
354      * <p>Converts the current number to a string using the specified number of significant 
355      * digits. Uses exponential or fixed-point notation depending on the size of the number 
356      * and the number of significant digits specified.</p>
357      * @param n The current number.
358      * @param precision The number of significant digits to appear in the returned string. 
359      * This may be a value between 1 and 21, inclusive. Implementations are allowed to 
360      * optionally support larger and smaller values of precision. If this argument is 
361      * undefined, the {@link #toString()} method is used instead to convert the number to 
362      * a base-10 value.
363      * @return A string representation of the current number that contains 
364      * <tt>precision</tt> significant digits. If <tt>precision</tt> is large 
365      * enough to include all the digits of the integer part of the number, the returned 
366      * string uses fixed-point notation. Otherwise, exponential notation is used with one 
367      * digit before the decimal place and <tt>precision - 1</tt> digits after the 
368      * decimal place. The number is rounded or padded with zeros as necessary.
369      * @throws RuntimeException JavaScript throws a <tt>RangeError</tt> if 
370      * <tt>digits</tt> is too small or too large. See {@link Js#err(Object)} and 
371      * {@link js.core.JsRangeError} for JS Simulation. Values between 1 and 20, inclusive, 
372      * will not cause a <tt>RangeError</tt>. Implementations are allowed to support 
373      * larger and smaller values as well.
374      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
375      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
376      * {@link js.core.JsTypeError} for JS Simulation.
377      * @see #toPrecision(Number)
378      * @see #toExponential(Number)
379      * @see #toExponential(Number, Object)
380      * @see #toFixed(Number)
381      * @see #toFixed(Number, Object)
382      * @see #toLocaleString(Number)
383      * @see #toString(Number)
384      * @see #toString(Number, Object)
385      * @see js.Value.Number#toPrecision(Object)
386      * @since 1.0
387      */
388     public static final String toPrecision(Number n, Object precision) {
389         return new Value.Number(n).toPrecision(precision);
390     }
391     /**
392      * <p>Converts the current number to a string using local number-formatting conventions.</p> 
393      * @param n The current number.
394      * @return An implementation-dependent string representation of the current number, 
395      * formatted according to local conventions, which may affect such things as the 
396      * punctuation characters used for the decimal point and the thousands separator.
397      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
398      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
399      * {@link js.core.JsTypeError} for JS Simulation.
400      * @see #toString(js.NumberLike)
401      * @see #toString(js.NumberLike, Object)
402      * @see #toExponential(js.NumberLike)
403      * @see #toExponential(js.NumberLike, Object)
404      * @see #toFixed(js.NumberLike)
405      * @see #toFixed(js.NumberLike, Object)
406      * @see #toPrecision(js.NumberLike)
407      * @see #toPrecision(js.NumberLike, Object)
408      * @see js.NumberLike#toLocaleString()
409      * @since 1.0
410      */
411     public static final String toLocaleString(NumberLike<?> n) {
412         return n.toLocaleString();
413     }
414     /**
415      * <p>Converts the current number to a string using local number-formatting conventions.</p> 
416      * @param n The current number.
417      * @return An implementation-dependent string representation of the current number, 
418      * formatted according to local conventions, which may affect such things as the 
419      * punctuation characters used for the decimal point and the thousands separator.
420      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
421      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
422      * {@link js.core.JsTypeError} for JS Simulation.
423      * @see #toString(Number)
424      * @see #toString(Number, Object)
425      * @see #toExponential(Number)
426      * @see #toExponential(Number, Object)
427      * @see #toFixed(Number)
428      * @see #toFixed(Number, Object)
429      * @see #toPrecision(Number)
430      * @see #toPrecision(Number, Object)
431      * @see js.Value.Number#toLocaleString()
432      * @since 1.0
433      */
434     public static final String toLocaleString(Number n) {
435         return new Value.Number(n).toLocaleString();
436     }
437     /**
438      * <p>Converts the current number to a base-10 string.</p> 
439      * @param n The current number.
440      * @return A base-10 string representation of the current number.
441      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
442      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
443      * {@link js.core.JsTypeError} for JS Simulation.
444      * @see #toString(js.NumberLike, Object)
445      * @see #toExponential(js.NumberLike)
446      * @see #toExponential(js.NumberLike, Object)
447      * @see #toFixed(js.NumberLike)
448      * @see #toFixed(js.NumberLike, Object)
449      * @see #toPrecision(js.NumberLike)
450      * @see #toPrecision(js.NumberLike, Object)
451      * @see #toLocaleString(js.NumberLike)
452      * @see js.NumberLike#toString()
453      * @since 1.0
454      */
455     public static final String toString(NumberLike<?> n) {
456         return n.toString();
457     }
458     /**
459      * <p>Converts the current number to a base-10 string.</p> 
460      * @param n The current number.
461      * @return A base-10 string representation of the current number.
462      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
463      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
464      * {@link js.core.JsTypeError} for JS Simulation.
465      * @see #toString(Number, Object)
466      * @see #toExponential(Number)
467      * @see #toExponential(Number, Object)
468      * @see #toFixed(Number)
469      * @see #toFixed(Number, Object)
470      * @see #toPrecision(Number)
471      * @see #toPrecision(Number, Object)
472      * @see #toLocaleString(Number)
473      * @see js.Value.Number#toString()
474      * @since 1.0
475      */
476     public static final String toString(Number n) {
477         return new Value.Number(n).toString();
478     }
479     /**
480      * <p>Converts the current number to a string. When the <tt>radix</tt> argument is 
481      * undefined or is specified as 10, the number is converted to a base-10 string.</p> 
482      * <p>Although the ECMAScript specification does not require implementations to honor 
483      * any other values for radix, all implementations in common use accept values between 
484      * 2 and 36.</p>
485      * @param n The current number.
486      * @param radix An optional argument that specifies the radix, or base, between 2 and 36, 
487      * in which the number should be represented. If undefined, base 10 is used. Note, 
488      * however, that the ECMAScript specification allows an implementation to return any 
489      * value if this argument is specified as any value other than 10.
490      * @return A string representation of the current number, in the specified base.
491      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
492      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
493      * {@link js.core.JsTypeError} for JS Simulation.
494      * @see #toString(js.NumberLike)
495      * @see #toExponential(js.NumberLike)
496      * @see #toExponential(js.NumberLike, Object)
497      * @see #toFixed(js.NumberLike)
498      * @see #toFixed(js.NumberLike, Object)
499      * @see #toPrecision(js.NumberLike)
500      * @see #toPrecision(js.NumberLike, Object)
501      * @see #toLocaleString(js.NumberLike)
502      * @see js.NumberLike#toString(Object)
503      * @since 1.0
504      */
505     public static final String toString(NumberLike<?> n, Object radix) {
506         return n.toString(radix);
507     }
508     /**
509      * <p>Converts the current number to a string. When the <tt>radix</tt> argument is 
510      * undefined or is specified as 10, the number is converted to a base-10 string.</p> 
511      * <p>Although the ECMAScript specification does not require implementations to honor 
512      * any other values for radix, all implementations in common use accept values between 
513      * 2 and 36.</p>
514      * @param n The current number.
515      * @param radix An optional argument that specifies the radix, or base, between 2 and 36, 
516      * in which the number should be represented. If undefined, base 10 is used. Note, 
517      * however, that the ECMAScript specification allows an implementation to return any 
518      * value if this argument is specified as any value other than 10.
519      * @return A string representation of the current number, in the specified base.
520      * @throws RuntimeException JavaScript throws a <tt>TypeError</tt> if this method 
521      * is invoked on an instance that is not a number. See {@link Js#err(Object)} and 
522      * {@link js.core.JsTypeError} for JS Simulation.
523      * @see #toString(Number)
524      * @see #toExponential(Number)
525      * @see #toExponential(Number, Object)
526      * @see #toFixed(Number)
527      * @see #toFixed(Number, Object)
528      * @see #toPrecision(Number)
529      * @see #toPrecision(Number, Object)
530      * @see #toLocaleString(Number)
531      * @see js.Value.Number#toString(Object)
532      * @since 1.0
533      */
534     public static final String toString(Number n, Object radix) {
535         return new Value.Number(n).toString(radix);
536     }
537 }