Home / Docs / Standard library / Built-in methods

bit_not

Release v0.4.0Edition 0.2 and later

A built-in method, resolved by the type of its receiver (spec/14 §2). Edition 0.2 and later.

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

Total; its result is only known to be in the type's range (spec/18 §5).

Receiver

Returns

F: each bit of a flipped, on the two's-complement bits of the width; it never fails.

See also

bit_and, bit_or, bit_xor

Example

src/shop.unauna
module shop

--- Every bit of a value flipped, unsigned and signed.
pub main() -> Unit
  uses @console: Console[print]
=
  let empty: U8 = 0
  let full = empty.bit_not()
  let bottom: I8 = -128
  let top = bottom.bit_not()
  @console.print("{full}")
  @console.print("{top}")

una run . prints:

Output
255
127

Specification

Generated from una v0.4.0 (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.