Code covered by the BSD License  

Highlights from
Extended Brookshear Machine emulator and assembler

image thumbnail
from Extended Brookshear Machine emulator and assembler by David Young
Emulator and assembler for a simple computer, a teaching aid for computer science courses.

f82dble(f)
function d = f82dble(f)
%F82DBLE converts Brookshear 1-byte float to double
%   D = F82DBLE(F) returns the value of F, which is treated as an 8-bit
%   floating point number in the format specified by Brookshear.

%   Copyright 2008 University of Sussex and David Young

m = bitand(f, hex2dec('f'));
e = bitshift(bitand(f, hex2dec('70')), -4);
s = bitget(f, 8);

d = double(m) * 2^(double(e)-8);
if s
    d = -d;
end

end

Contact us at files@mathworks.com