Skip to Main Content Skip to Search
Product Documentation

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

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

See Also

bin2num | hex2num | num2bin | num2hex

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS