A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Number/toPrecision below:

toPrecision · WebPlatform Docs

toPrecision Summary

Represents a number either in exponential or fixed-point notation with a specified number of digits.

Syntax
toPrecision([ precision ])
precision
Optional. The number of significant digits. Must be in the range 1 - 21, inclusive.
Return Value

For numbers in exponential notation, precision - 1 digits are returned after the decimal point. For numbers in fixed notation, precision significant digits are returned.

If precision is not supplied or is undefined , toString() is called instead.

Examples

Using toPrecision to format the decimal presentation of a number.

var pie = 3.14159;


pie.toPrecision();


pie.toPrecision(5);


pie.toPrecision(2);


pie.toPrecision(1);



(1234.5).toPrecision(2);

Remarks Throws

RangeError when a fractionDigits outside the bounds of 1 - 21 (inclusive) was given.

See also Other articles External resources Specification

15.7.4.7 Number.prototype.toPrecision(precision)

ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4