---
title: "f64: shader function examples, uses and input limits"
description: "Widening an f32 preserves its value in a representation with more precision for later arithmetic."
url: https://typeshade.dev/reference/functions/f64/
language: en
---

# `f64`

Function

Widening an `f32` preserves its value in a representation with more precision for later arithmetic.

## Compare examples

Widening to `f64` cannot recover precision lost when the value was first converted to `f32`. Exactly representable values stay unchanged.

**Example 1`f64(f32(0.1))`**

**Result**

`0.10000000149011612`

**Example 2`f64(f32(1.5))`**

**Result**

`1.5`

**Example 3`f64(f32(16777217))`**

**Result**

`16777216`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it for reducing additional rounding during sensitive calculations.

## Inputs and limits

Widening cannot recover lost input digits. This compiler emulates `f64` in software; it is not a request for native hardware double precision.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`f32`](https://typeshade.dev/reference/functions/f32/)
- [`vec2f64`](https://typeshade.dev/reference/functions/vec2f64/)

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Widens an `f32` to the emulated double `f64`.

## Syntax

```ts
declare function f64(x: number): f64
```

A `number` in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

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

A `number` you write as a type is inferred from its uses, and `f32`, `i32` and `u32` fix a width; [the TypeScript constructs page](https://typeshade.dev/guide/language/from-typescript/) carries that row with the compiler's emit.

## Parameters

- `x` `number`

## Return value

`f64`

## Description

A value that is already `f64` is returned as it is; cast an integer to `f32` first.

## Targets

**WGSL**

Rewritten into a pair of `f32` lanes before either backend runs.

**GLSL ES 3.00**

Rewritten into a pair of `f32` lanes before either backend runs.

## Examples

- [`gallery/fp64-burning-ship-twin/fp64-burning-ship-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-burning-ship-twin/)
- [`gallery/fp64-cancellation-twin/fp64-cancellation-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-cancellation-twin/)
- [`gallery/fp64-checker-plane-twin/fp64-checker-plane-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-checker-plane-twin/)
- [`gallery/fp64-clock-twin/fp64-clock-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-clock-twin/)
- [`gallery/fp64-deep-zoom-twin/fp64-deep-zoom-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-deep-zoom-twin/)
- [`gallery/fp64-julia-twin/fp64-julia-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-julia-twin/)
- [`gallery/fp64-loran-twin/fp64-loran-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-loran-twin/)
- [`gallery/fp64-mandelbrot-de-twin/fp64-mandelbrot-de-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-mandelbrot-de-twin/)
- [`gallery/fp64-newton-twin/fp64-newton-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-newton-twin/)
- [`gallery/fp64-rtc-twin/fp64-rtc-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-rtc-twin/)
- [`gallery/fp64-sine-sweep-twin/fp64-sine-sweep-twin.shade.ts`](https://typeshade.dev/guide/examples/fp64-sine-sweep-twin/)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#f64)
- [`f64()` in `typeshade/core/ir`](https://typeshade.dev/api/f64/)
