API

group arith

Public function definitions and types for Yc’s safe arithmetic.

Typedefs

typedef long long llong

A single word typedef for long long.

Functions

static inline uint16_t y_lrot16(uint16_t x, y_sint k)

Left rotate 16-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 16-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 16.

Returns:

The rotated 16-bit value.

static inline uint16_t y_rrot16(uint16_t x, y_sint k)

Right rotate 16-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 16-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 16.

Returns:

The rotated 16-bit value.

static inline uint32_t y_lrot32(uint32_t x, y_sint k)

Left rotate 32-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 32-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 32.

Returns:

The rotated 32-bit value.

static inline uint32_t y_rrot32(uint32_t x, y_sint k)

Right rotate 32-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 32-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 32.

Returns:

The rotated 32-bit value.

static inline uint64_t y_lrot64(uint64_t x, y_sint k)

Left rotate 64-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 64-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 64.

Returns:

The rotated 64-bit value.

static inline uint64_t y_rrot64(uint64_t x, y_sint k)

Right rotate 64-bit x by k bits.

This has no undefined behavior.

Parameters:
  • x – 64-bit value to rotate.

  • k – Number of bits to rotate. The true rotation amount is this param modulus 64.

Returns:

The rotated 64-bit value.