This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

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

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

See also