---
title: "f32 / float: WGSL·GLSL 함수 뜻과 사용법, 계산 예제와 입력 범위 및 주의점"
description: "숫자를 binary32로 표현할 수 있는 값으로 반올림합니다. 숫자를 일반적인 셰이더 연산의 정밀도로 변환할 때 사용합니다. 큰 정수는 이웃한 값과 구분되지 않을 수 있습니다. 변환으로 이미 잃은 정밀도를 되찾지는 못합니다."
url: https://typeshade.dev/ko/reference/functions/f32/
language: ko
---

# `f32`

함수

숫자를 binary32로 표현할 수 있는 값으로 반올림합니다.

**다른 언어의 관련 이름**

관련 연산은 인수, 지원 범위와 의미가 다를 수 있습니다. 다른 언어의 이름을 TypeShade 별칭으로 사용할 수는 없습니다. 지원하는 형태와 제한은 대상 언어에 따라 다릅니다.

- GLSL: `float`

[대상별 출력](https://typeshade.dev/ko/reference/functions/f32/#targets)

## 예제 비교

서로 이웃한 큰 정수가 같은 binary32 값으로 반올림될 수 있습니다. 소수 입력도 표현 가능한 값으로 반올림됩니다.

**예제 1`f32(0.1)`**

**결과**

`0.10000000149011612`

**예제 2`f32(16777216)`**

**결과**

`16777216`

**예제 3`f32(16777217)`**

**결과**

`16777216`

예제는 설명용 계산 모델이며 GPU를 실행하지 않습니다. 정확한 호출 형식은 아래 컴파일러 참고 자료에서 설명합니다. 소수 결과는 표시할 때 반올림했습니다. 각 예제는 명시한 전제를 따릅니다. 실제 셰이더의 결과는 대상 언어의 정밀도와 실행 규칙에 따릅니다.

## 활용

숫자를 일반적인 셰이더 연산의 정밀도로 변환할 때 사용합니다.

## 입력 범위와 주의사항

큰 정수는 이웃한 값과 구분되지 않을 수 있습니다. 변환으로 이미 잃은 정밀도를 되찾지는 못합니다.

셰이더의 입력 규칙과 정밀도는 [WGSL](https://www.w3.org/TR/WGSL/)과 [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)에서 규정합니다.

## 관련 함수

- [`f64`](https://typeshade.dev/ko/reference/functions/f64/)
- [`quantizeToF16`](https://typeshade.dev/ko/reference/functions/quantizeToF16/)
- [`bitcast`](https://typeshade.dev/ko/reference/functions/bitcast/)

**WGSL**

`f32(a)`

**GLSL ES 3.00**

`float(a)`

시그니처와 이름 아래 문장, 컴파일러 메시지는 커밋 af54ddad5의 컴파일러가 쓴 영어 원문입니다.

Casts a number to `f32` single-precision floating-point by inlining a literal value rounded to 32-bit precision.

## 구문

```ts
declare function f32(): f32
declare function f32(x: number | bool): f32
```

매개변수나 반환 위치에 쓰인 `number`는 스칼라가 들어갈 자리입니다. 앰비언트 파일은 GPU 스칼라를 브랜드가 붙은 number로 선언하고 그 브랜드는 선택이라서, 리터럴도 브랜드가 붙은 스칼라도 이 자리에 들어갑니다.

`type f32 = number & { readonly [f32Tag]?: true }`

타입으로 쓴 `number`는 쓰이는 곳을 보고 추론하며, `f32`, `i32`, `u32`는 너비를 고정합니다. 그 행과 컴파일러가 낸 결과는 [TypeScript에서](https://typeshade.dev/ko/guide/language/from-typescript/) 페이지에 있습니다.

## 매개변수

- `x` 선택 사항 `number | bool`

## 반환값

`f32`

## 설명

This is equivalent to `Math.fround(x)`.

## 대상별 출력

**WGSL**

`f32(a)`

**GLSL ES 3.00**

`float(a)`

## 예제

- [`path/tile-pattern/tile-pattern.shade.ts`](https://typeshade.dev/ko/guide/examples/tile-pattern/)
- [`gallery/capsule-corp-namek-class/capsule-corp-namek-class.shade.ts`](https://typeshade.dev/ko/guide/examples/capsule-corp-namek-class/)
- [`gallery/domain-warp-twin/domain-warp-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/domain-warp-twin/)
- [`gallery/hillshade-twin/hillshade-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/hillshade-twin/)
- [`gallery/julia-twin/julia-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/julia-twin/)
- [`gallery/kaleidoscope-twin/kaleidoscope-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/kaleidoscope-twin/)
- [`gallery/mandelbrot-twin/mandelbrot-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/mandelbrot-twin/)
- [`gallery/ocean-twin/ocean-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/ocean-twin/)
- [`gallery/path-tracer/path-tracer.shade.ts`](https://typeshade.dev/ko/guide/examples/path-tracer/)
- [`gallery/plasma-twin/plasma-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/plasma-twin/)
- [`gallery/rt-renderer-class/rt-renderer-class.shade.ts`](https://typeshade.dev/ko/guide/examples/rt-renderer-class/)
- [`gallery/starfield-twin/starfield-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/starfield-twin/)
- [`gallery/tunnel-twin/tunnel-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/tunnel-twin/)
- [`gallery/voronoi-twin/voronoi-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/voronoi-twin/)
- [`gallery/fp64-burning-ship-twin/fp64-burning-ship-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-burning-ship-twin/)
- [`gallery/fp64-cancellation-twin/fp64-cancellation-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-cancellation-twin/)
- [`gallery/fp64-checker-plane-twin/fp64-checker-plane-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-checker-plane-twin/)
- [`gallery/fp64-clock-twin/fp64-clock-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-clock-twin/)
- [`gallery/fp64-deep-zoom-twin/fp64-deep-zoom-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-deep-zoom-twin/)
- [`gallery/fp64-julia-twin/fp64-julia-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-julia-twin/)
- [`gallery/fp64-lane-stripes/fp64-lane-stripes.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-lane-stripes/)
- [`gallery/fp64-loran-twin/fp64-loran-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-loran-twin/)
- [`gallery/fp64-mandelbrot-de-twin/fp64-mandelbrot-de-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-mandelbrot-de-twin/)
- [`gallery/fp64-newton-twin/fp64-newton-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-newton-twin/)
- [`gallery/fp64-rtc-twin/fp64-rtc-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-rtc-twin/)
- [`gallery/fp64-sine-sweep-twin/fp64-sine-sweep-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-sine-sweep-twin/)
- [`gallery/array-literal-ramp/array-literal-ramp.shade.ts`](https://typeshade.dev/ko/guide/examples/array-literal-ramp/)
- [`gallery/array-methods/array-methods.shade.ts`](https://typeshade.dev/ko/guide/examples/array-methods/)
- [`gallery/bit-bump/bit-bump.shade.ts`](https://typeshade.dev/ko/guide/examples/bit-bump/)
- [`gallery/block-scope/block-scope.shade.ts`](https://typeshade.dev/ko/guide/examples/block-scope/)
- [`gallery/class-builder/class-builder.shade.ts`](https://typeshade.dev/ko/guide/examples/class-builder/)
- [`gallery/class-parts/class-parts.shade.ts`](https://typeshade.dev/ko/guide/examples/class-parts/)
- [`gallery/class-syntax/class-syntax.shade.ts`](https://typeshade.dev/ko/guide/examples/class-syntax/)
- [`gallery/clip-planes/clip-planes.shade.ts`](https://typeshade.dev/ko/guide/examples/clip-planes/)
- [`gallery/closures/closures.shade.ts`](https://typeshade.dev/ko/guide/examples/closures/)
- [`gallery/cube-array-gather/cube-array-gather.shade.ts`](https://typeshade.dev/ko/guide/examples/cube-array-gather/)
- [`gallery/cube-env/cube-env.shade.ts`](https://typeshade.dev/ko/guide/examples/cube-env/)
- [`gallery/cutout/cutout.shade.ts`](https://typeshade.dev/ko/guide/examples/cutout/)
- [`gallery/feedback-trail/feedback-trail.shade.ts`](https://typeshade.dev/ko/guide/examples/feedback-trail/)
- [`gallery/generic-helpers/generic-helpers.shade.ts`](https://typeshade.dev/ko/guide/examples/generic-helpers/)
- [`gallery/hello-uniform/hello-uniform.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-uniform/)
- [`gallery/hello-uniform-struct/hello-uniform-struct.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-uniform-struct/)
- [`gallery/higher-order/higher-order.shade.ts`](https://typeshade.dev/ko/guide/examples/higher-order/)
- [`gallery/id-pick/id-pick.shade.ts`](https://typeshade.dev/ko/guide/examples/id-pick/)
- [`gallery/imported-noise/imported-noise.shade.ts`](https://typeshade.dev/ko/guide/examples/imported-noise/)
- [`gallery/inferred-returns/inferred-returns.shade.ts`](https://typeshade.dev/ko/guide/examples/inferred-returns/)
- [`gallery/integer-math/integer-math.shade.ts`](https://typeshade.dev/ko/guide/examples/integer-math/)
- [`gallery/loop-kernel/loop-kernel.shade.ts`](https://typeshade.dev/ko/guide/examples/loop-kernel/)
- [`gallery/loop-reduction/loop-reduction.shade.ts`](https://typeshade.dev/ko/guide/examples/loop-reduction/)
- [`gallery/loops-over-data/loops-over-data.shade.ts`](https://typeshade.dev/ko/guide/examples/loops-over-data/)
- [`gallery/module-const/module-const.shade.ts`](https://typeshade.dev/ko/guide/examples/module-const/)
- [`gallery/msaa-resolve/msaa-resolve.shade.ts`](https://typeshade.dev/ko/guide/examples/msaa-resolve/)
- [`gallery/normal-matrix/normal-matrix.shade.ts`](https://typeshade.dev/ko/guide/examples/normal-matrix/)
- [`gallery/packed-bytes/packed-bytes.shade.ts`](https://typeshade.dev/ko/guide/examples/packed-bytes/)
- [`gallery/packing-bitcast/packing-bitcast.shade.ts`](https://typeshade.dev/ko/guide/examples/packing-bitcast/)
- [`gallery/palette-const/palette-const.shade.ts`](https://typeshade.dev/ko/guide/examples/palette-const/)
- [`gallery/private-state/private-state.shade.ts`](https://typeshade.dev/ko/guide/examples/private-state/)
- [`gallery/rng-method/rng-method.shade.ts`](https://typeshade.dev/ko/guide/examples/rng-method/)
- [`gallery/sample-branch/sample-branch.shade.ts`](https://typeshade.dev/ko/guide/examples/sample-branch/)
- [`gallery/separable-blur/separable-blur.shade.ts`](https://typeshade.dev/ko/guide/examples/separable-blur/)
- [`gallery/shadow-compare/shadow-compare.shade.ts`](https://typeshade.dev/ko/guide/examples/shadow-compare/)
- [`gallery/storage-texture/storage-texture.shade.ts`](https://typeshade.dev/ko/guide/examples/storage-texture/)
- [`gallery/textured-quad/textured-quad.shade.ts`](https://typeshade.dev/ko/guide/examples/textured-quad/)
- [`gallery/twin-structs/twin-structs.shade.ts`](https://typeshade.dev/ko/guide/examples/twin-structs/)
- [`gallery/uniform-array/uniform-array.shade.ts`](https://typeshade.dev/ko/guide/examples/uniform-array/)

## 함께 보기

- [함수](https://typeshade.dev/ko/reference/functions/)
- [내장 함수 표](https://typeshade.dev/ko/guide/language/builtins/#casts)
- [`Math.fround`](https://typeshade.dev/ko/reference/math/fround/)
- [`typeshade/core/ir`의 `f32()`](https://typeshade.dev/ko/api/f32/)
