---
title: "float"
description: "A plain number as an expression."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L504"
---

# float

A plain number as an expression.

```ts
float(n: number): Expr
```

Import `math` from `shaders/std` and use `math.float`.

Rarely needed: every word here accepts numbers directly. Reach for it when something wants an expression and you only have a constant.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `n` | `number` |  |

## Example

```ts
const half = float(0.5)
```

## See also

- [`vec2`](/docs/primitives/math/vec2) — A 2D vector from two values.
- [`vec3`](/docs/primitives/math/vec3) — A 3D vector from three values, often a color without alpha.
- [`vec4`](/docs/primitives/math/vec4) — A 4D vector, usually the final color with alpha.

## Used by

[CarbonFiber](/docs/components/carbonfiber), [Chrome](/docs/components/chrome), [Crystal](/docs/components/crystal), [Frost](/docs/components/frost), [Goo](/docs/components/goo), [Heatmap](/docs/components/heatmap), [Hologram](/docs/components/hologram), [Holographic](/docs/components/holographic), [Irradiance](/docs/components/irradiance), [Nebula](/docs/components/nebula), [StudioBackground](/docs/components/studiobackground), [Water](/docs/components/water)