zigzag static method

int zigzag(
  1. int value
)

Maps a signed integer onto an unsigned one, keeping small magnitudes small.

Implementation

static int zigzag(int value) => value < 0 ? -2 * value - 1 : 2 * value;