# Introduction¶

The Classiq Arithmetic package includes various classical functions for arithmetic. 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 basis with Little Endian ordering and in general, uses the minimal number of qubits to represent the solution. Additional qubits are added to account for overflow and sign when needed and not otherwise stated.

As a quick refresher, binary numbers are converted to integer 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 left most bit) has value of $$2^{3-1}=2^{2}=4$$ . The number represented in this case is:

$1*(2^2) + 0*(2^1) + 1*(2^0) + 1*(2^{-1}) + 1*(2^{-2}) = 5.75$

For signed representation we use 2-complement method, where the MSB is multiplied by -1. The unsigned value is:

$-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. Each quantum register has three properties:

1. Size - which is 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
}
}


Numbers with decimals point are converted to fix point with five bit precision by default since most decimals have infinite representations in binary. For example the innocent looking number 0.1 is actually infinitely long in binary : $$0.1 = (0.00011001100110011...)_2$$. Therefore, the float number defined in "arg",

{
"arg": 0.1
}


is $$(0.00011)_2 = 0.09375$$. It is possible to specify a higher precision by changing the max_fraction_places value,

{
"arg": {
"float_value": 0.1,
"max_fraction_places": 9
}
}


so that the number evaluated is closer to the float value, $$(0.000110011)_2 = 0.099609375$$