# 3.3.11. pci.api.ops module¶

The module `pci.api.ops` contains various functions to compare and round floating point numbers.

New in version 2018.

## 3.3.11.1. Constants¶

`pci.api.ops.``EQZERO_EPSILON` = 1e-09

Epsilon value to use to compare if two values are the same

## 3.3.11.2. Comparison functions¶

`pci.api.ops.``eqepsilon`(v0, v1, epsilon=1e-09)

Check if values of v0 and v1 are equal. The values are considered to be equal if the difference between them is less than epsilon.

`pci.api.ops.``eqzero`(val, epsilon=1e-09)

Check if a value of val is zero. The value is considered to be equal to zero if its absolute value is less than epsilon.

## 3.3.11.3. Rounding functions¶

`pci.api.ops.``general_round`(value, ndigits=0, part=0.0)

Round the the parameter value to ndigits precision.

Rounding is done away from 0, for example

 ```1 2 3``` ```from pci.api.ops import general_round print(general_round(0.5)) print(general_round(-0.5)) ```

The above code will generate the following output.

 ```1 2``` ```1.0 -1.0 ```

The ndigits is the decimal place that value will be rounded to. Values are rounded to the closest multiple of 10 to the power precision. Positive values of ndigits produce more precise results (more significant digits). Negative values of ndigits produce less precise results (less significant digits).

part dictates how many partitions to break the value into. To round to every 1/2 pass 2, every 1/3 pass 3. The value should be 1.0 or greater. Values smaller than 1 and fractional partitions will work and the results are deterministic - it is just that it is harder to understand their meaning.

The number of partitions, part affects the digits. If partitions is greater than 1 then it adds another level of ndigits. A partition of 1 means that only the ndigits is used. If the number of partitions is 0 then it is the same having as 1 partition and the built in function :func: round is called: round(value, ndigits).

`pci.api.ops.``round_pixel_size`(pixel_size)

Round the pixel size, pixel_size to a nice human friendly number. It puts the pixel size in a range and from that range determines how many decimal places are needed.

This function returns a single value output_pixel_size.

`pci.api.ops.``round_pixel_size_square`(pixel_size)

Round the pixel size, pixel_size to a nice human friendly number. It puts the pixel size in a range and from that range determines how many decimal places are needed.

This function returns a tuple of (output_pixel_size, output_pixel_size).

`pci.api.ops.``round_to_nearest_power`(value, power)

Round the value to the nearest power of power. value may be any float value including negative numbers. power must be a value greater than 0. If value is 0 then 0 is returned. If power is 1 then value is returned.