Cody

Solution 358434

Submitted on 23 Nov 2013 by Alfonso Nieto-Castanon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% assert(double2half(2^(-24)) == uint16(1)) % Smallest number
n = -15
2   Pass
%% assert(double2half(2^(-25)) == uint16(1)) % Rounds up to smallest number
n = -15
3   Pass
%% assert(double2half(2^(-26)) == uint16(0)) % Rounds down to zero
n = -15
4   Pass
%% assert(bin2dec('0 01111 0000000000') == double2half(1))
n = 0
5   Pass
%% assert(bin2dec('0 01111 0000000001') == double2half(1 + 2^(-10)))
n = 0
6   Pass
%% assert(bin2dec('1 10000 0000000000') == double2half(-2))
n = 1
7   Pass
%% assert(bin2dec('0 11110 1111111111') == double2half(65504))
n = 15
8   Pass
%% assert(bin2dec('0 00001 0000000000') == double2half(2^(-14)))
n = -14
9   Pass
%% assert(bin2dec('0 00000 1111111111') == double2half(2^(-14) - 2^(-24)))
n = -15
10   Pass
%% assert(bin2dec('0 00000 0000000001') == double2half(2^(-24)))
n = -15
11   Pass
%% assert(bin2dec('0 00000 0000000000') == double2half(0))
n = -15
12   Pass
%% assert(bin2dec('1 00000 0000000000') == double2half(-0))
13   Pass
%% assert(bin2dec('0 11111 0000000000') == double2half(inf))
n = 15
14   Pass
%% assert(bin2dec('1 11111 0000000000') == double2half(-inf))
n = 15
15   Pass
%% assert(bin2dec('0 01101 0101010101') == double2half(0.33325))
n = -2