Skip to content


The Classiq arithmetic package includes various classical functions for arithmetic operations. The functions are optimized for quantum computation, include multiple implementations, and support classical input (fixed-point or integer) and quantum input (qubits), signed or unsigned.

The calculation is done in binary with Little Endian ordering. In general, it uses the minimal number of qubits to represent the solution. Additional qubits are added to account for overflow and sign when needed and are not otherwise stated.

As a quick refresher, binary numbers are converted to integers by multiplying each bit by the relevant power of two. The binary number 101.11 has three bits left of the radix point so the MSB (most significant bit i.e., the leftmost bit) has a value of \(2^{3-1}=2^{2}=4\). This is the number represented in this case:

\[ 1*(2^2) + 0*(2^1) + 1*(2^0) + 1*(2^{-1}) + 1*(2^{-2}) = 5.75 \]

Signed representation uses the two-complement method, where the MSB is multiplied by -1.

This is the unsigned value:

\[ -1*(2^2) + 0*(2^1) + 1*(2^0) + 1*(2^{-1}) + 1*(2^{-2}) = -2.25 \]

A quantum register can contain a single number or superposition of numbers represented in binary form. Each quantum register has three properties:

  1. size - the total number of qubits used.
  2. fraction_places - the number of qubits used for the fraction part.
  3. is_signed - indicating whether the value stored is signed or unsigned.
  "arg": {
    "size": 3,
    "fraction_places": 1,
    "is_signed": true

Basic Functions

Advanced Functions