# num2int

Convert number to signed integer using `quantizer` object

## Syntax

``y = num2int(q,x)``

## Description

example

````y = num2int(q,x)` converts numeric values in `x` to output `y` containing integers using the data type properties specified by the fixed-point `quantizer` object `q`. If `x` is a cell array containing numeric matrices, then `y` will be a cell array of the same dimension.[`y1`,`y2`,…] = num2int(`q`,`x1`,`x2`,…) uses `q` to convert numeric values `x1`, `x2`,… to integers `y1`, `y2`,….```

## Examples

collapse all

All the two's complement 4-bit numbers in fractional form are given by:

```x = [0.875 0.375 -0.125 -0.625 0.750 0.250 -0.250 -0.750 0.625 0.125 -0.375 -0.875 0.500 0.000 -0.500 -1.000];```

Define a `quantizer` object to use for conversion.

`q = quantizer([4 3]);`

Use `num2int` to convert to signed integer.

`y = num2int(q,x)`
```y = 7 3 -1 -5 6 2 -2 -6 5 1 -3 -7 4 0 -4 -8```

## Input Arguments

collapse all

Data type format to use for conversion, specified as a fixed-point `quantizer` object.

Example: `q = quantizer([5 4]);`

Numeric values to convert, specified as a scalar, vector, matrix, multidimensional array, or cell array.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `cell`
Complex Number Support: Yes

## Algorithms

• When `q` is a fixed-point `quantizer` object, f is equal to `fractionlength`(`q`), and x is numeric:

`$y=x×{2}^{f}$`

• `num2int` is meaningful only for fixed-point `quantizer` objects. When `q` is a floating-point `quantizer` object, x is returned unchanged (y = x).

• `y` is returned as a double, but the numeric values will be integers, also known as floating-point integers or flints.