Math.fround()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2015๋ 7์โฉ.
Math.fround()
ํจ์๋ single precision ํฌ๋งท์ผ๋ก ํํํ ์ ์๋ ์ค์๋ค ์ค์์ ๊ฐ์ฅ ๊ฐ๊น์ด ์ซ์๋ฅผ ๋ฆฌํดํฉ๋๋ค.
๋ฌธ๋ฒ
js
Math.fround(x);
ํ๋ผ๋ฉํฐ
x
-
์ซ์.
์ค๋ช
fround()
๊ฐ Math
๊ฐ์ฒด์ ์ ์ ๋ฉ์๋์ด๊ธฐ ๋๋ฌธ์, ๋ฐ๋์ Math.fround()
๊ฐ์ ํํ๋ก ์ฌ์ฉํด์ผ ํฉ๋๋ค. Math
๊ฐ์ฒด๋ฅผ ์ง์ ๋ง๋ค์ด์ ํธ์ถํ๋ ๋ฐฉ์์ผ๋ก ์ฌ์ฉํ์ง ์์ต๋๋ค (Math
๋ ์์ฑ์๊ฐ ์๋๋๋ค).
์์
Math.fround() ์ฌ์ฉ๋ฒ
js
Math.fround(0); // 0
Math.fround(1); // 1
Math.fround(1.337); // 1.3370000123977661
Math.fround(1.5); // 1.5
Math.fround(NaN); // NaN
Polyfill
๋ง์ฝ Float32Array
๊ฐ ์ง์๋๋ค๋ฉด, Math.fround() ๋ฅผ ๋ค์ ํจ์๋ก ํ๋ด๋ผ ์ ์์ต๋๋ค.
js
Math.fround =
Math.fround ||
(function (array) {
return function (x) {
return ((array[0] = x), array[0]);
};
})(Float32Array(1));
๋ช ์ธ
Specification |
---|
ECMAScriptยฎ 2026 Language Specification # sec-math.fround |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ