Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# num2int

Convert number to signed integer

## Syntax

```y = num2int(q,x) [y1,y,...] = num2int(q,x1,x,...) ```

## Description

`y = num2int(q,x)` uses `q.format` to convert numeric `x` to an integer.

`[y1,y,...] = num2int(q,x1,x,...)` uses `q.format` to convert numeric values `x1, x2,...` to integers `y1,y2,...`

## Examples

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]; q=quantizer([4 3]); y = num2int(q,x) y = 7 3 -1 -5 6 2 -2 -6 5 1 -3 -7 4 0 -4 -8 ```

## Algorithms

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

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

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

Get trial now