| Contents | Index |
c = reinterpretcast(a, T)
c = reinterpretcast(a, T) converts the input a to the data type specified by numerictype object T without changing the underlying data. The result is returned in fi object c.
The input a must be a built-in integer or a fi object with a fixed-point data type. T must be a numerictype object with a fully specified fixed-point data type. The word length of inputs a and T must be the same.
The reinterpretcast function differs from the MATLAB typecast and cast functions in that it only operates on fi objects and built-in integers, and it does not allow the word length of the input to change.
In the following example, a is a signed fi object with a word length of 8 bits and a fraction length of 7 bits. The reinterpretcast function converts a into an unsigned fi object c with a word length of 8 bits and a fraction length of 0 bits. The real-world values of a and c are different, but their binary representations are the same.
a = fi([-1 pi/4], true, 8, 7)
T = numerictype(false, 8, 0);
c = reinterpretcast(a, T)
a =
-1.0000 0.7891
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 8
FractionLength: 7
c =
128 101
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 8
FractionLength: 0To verify that the underlying data has not changed, compare the binary representations of a and c:
binary_a = bin(a) binary_c = bin(c) binary_a = 10000000 01100101 binary_c = 10000000 01100101
cast | fi | numerictype | typecast

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 |