A RetroSearch Logo

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

Search Query:

Showing content from https://developer.cdn.mozilla.net/ja/docs/Web/JavaScript/Reference/Errors/Precision_range below:

RangeError: precision is out of range - JavaScript

RangeError: precision is out of range

JavaScript の例外 "precision is out of range" は、 toFixed または toPrecision に 0 から 20 (または 21) までの範囲外の数値が渡された場合に発生します。

エラーメッセージ
RangeError: The number of fractional digits is out of range (Edge)
RangeError: The precision is out of range (Edge)
RangeError: precision {0} out of range (Firefox)
RangeError: toExponential() argument must be between 0 and 20 (Chrome)
RangeError: toFixed() digits argument must be between 0 and 20 (Chrome)
RangeError: toPrecision() argument must be between 1 and 21 (Chrome)
エラーの種類 エラーの原因

これらのメソッドのいずれかで、 範囲外の精度を引数を使用しています。

これらのメソッドで許可されている範囲は、通常 0 と 20(または 21)の間です。しかし、ECMAScript 仕様では、この範囲の拡張が認められています。

例 無効なケース
(77.1234).toExponential(-1); // RangeError
(77.1234).toExponential(101); // RangeError

(2.34).toFixed(-100); // RangeError
(2.34).toFixed(1001); // RangeError

(1234.5).toPrecision(-1); // RangeError
(1234.5).toPrecision(101); // RangeError
有効な場合
(77.1234).toExponential(4); // 7.7123e+1
(77.1234).toExponential(2); // 7.71e+1

(2.34).toFixed(1); // 2.3
(2.35).toFixed(1); // 2.4 (この場合は丸めが発生することに注意してください)

(5.123456).toPrecision(5); // 5.1235
(5.123456).toPrecision(2); // 5.1
(5.123456).toPrecision(1); // 5
関連情報

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