%% Convert 8-Bit Integer to Single Precision
% Create a 1-by-4 vector of 8-bit integers.

X = int8([77 60 43 26])

% Convert the four 8-bit integers, which use 4 bytes (32 bits) of storage, to a single-precision number that also uses 4 bytes of storage.

Y = typecast(X,'single')

% Show the bit patterns in hexadecimal representation. In hexadecimal notation, 1 byte (8 bits) is represented by two digits. The typecast function rearranges the bit patterns without modifying the data.

format hex
X
Y = typecast(X,'single')

%
% Copyright 2019 The MathWorks, Inc.