---
title: "wrapping_sub"
url: https://una-lang.org/en/docs/std/builtin/wrapping_sub/
release: v0.4.0
edition: "0.2 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/builtins.json
---

# wrapping_sub

A built-in method, resolved by the type of its receiver ([`spec/14 §2`](https://una-lang.org/en/docs/spec/14-standard-library/#s2)). Edition 0.2 and later.

```una
a.wrapping_sub(by: F) -> F
  where a: F, one of I8, I16, I32, I64, U8, U16, U32, U64
```

Total: the exact result reduced into the type's range modulo `2^w`, where `w` is its width (`spec/18 §5`).

## Receiver

- `F, one of I8, I16, I32, I64, U8, U16, U32, U64`: a fixed\-width integer `a`\, of one of the eight types `I8`\, `I16`\, `I32`\, `I64`\, `U8`\, `U16`\, `U32` and `U64`\; the result has its type

## Parameters

- `by`: the other operand\, of the same type

## Returns

`F`: the exact difference reduced into the range of the type modulo `2^w`\, where `w` is its width\: below the smallest value it goes on from the largest\; it never fails.

## See also

[`saturating_sub`](https://una-lang.org/en/docs/std/builtin/saturating_sub/)

## Example

`src/shop.una`

```una
module shop

--- A one-byte counter that goes on from the largest value below the smallest.
pub main() -> Unit
  uses @console: Console[print]
=
  let low: U8 = 3
  let back = low.wrapping_sub(by: 5)
  let bottom: I8 = -128
  let past = bottom.wrapping_sub(by: 1)
  @console.print("{back}")
  @console.print("{past}")
```

`una run .` prints:

```text
254
127
```

## Specification

- [`spec/18 §5`](https://una-lang.org/en/docs/spec/18-fixed-width-integers/#s5)

Generated from una v0.4.0 ([`docs/std/builtins.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/builtins.json), which is not part of the specification): built-in methods have no declaration, so una writes these signature lines and tests each against its checker. The specification governs: [`spec/14 §2`](https://una-lang.org/en/docs/spec/14-standard-library/#s2).
