Interface JSNumberFunctions

All Superinterfaces:
JSObjectFunctions
All Known Implementing Classes:
JSNumber

public interface JSNumberFunctions extends JSObjectFunctions
  • Method Details

    • toFixed

      JSString toFixed(JSNumber fractionDigits)
      function toFixed(fractionDigits) format a number using fixed-point notation.

      Example

      var n = 12345.6789;
      n.toFixed(); //returns 12346: note rounding up
      n.toFixed(1); //returns 12345.7: note rounding up
      n.toFixed(6); //returns 12345.678900: note zeros
      (1.23e+20).toFixed(2); //returns 123000000000000000000.00
      
      Parameters:
      fractionDigits - The number of digits to appear after the decimal point. If omitted it is treated as 0.
      Since:
      Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
      See Also:
    • toExponential

      JSString toExponential(JSNumber fractionDigits)
      function toExponential(fractionDigits) format a number using exponential notation.

      Example

      var n = 12345.6789;
      n.toExponential(1); //returns 1.2e+4
      n.toExponential(5); //returns 1.23457e+4
      n.toExponential(10); //returns 1.2345678900e+4
      n.toExponential(); //returns 1.23456789e+4
      
      Parameters:
      fractionDigits - The number of digits that appear after the decimal point.
      Since:
      Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
      See Also:
    • toPrecision

      JSString toPrecision(JSNumber fractionDigits)
      function toPrecision(precision) format the significant digits of a number.

      Example

      var n = 12345.6789;
      n.toPrecision(1); //returns 1e+4
      n.toPrecision(3); //returns 1.23e+4
      n.toPrecision(5); //returns 12346
      n.toPrecision(10); //returns 12345.67890
      
      Parameters:
      fractionDigits - The number of significant digits to appear in the returned string.
      Since:
      Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
      See Also: