Cody

Solution 1576785

Submitted on 6 Jul 2018
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   Fail
a = int8(1); b = int8(2); c = intOrfloat(a, b) assert(isequal(c,-1))

Error using * Integers can only be combined with integers of the same class, or scalar doubles. Error in intOrfloat (line 3) a + b - 2*b*isinteger(a); Error in Test1 (line 3) c = intOrfloat(a, b)

2   Pass
a = 1; b = 2; c = intOrfloat(a, b) assert(isequal(c,3))

c = 3

3   Fail
a = uint8(1); b = uint8(2); c = intOrfloat(a, b) assert(isequal(c,0))

Error using * Integers can only be combined with integers of the same class, or scalar doubles. Error in intOrfloat (line 3) a + b - 2*b*isinteger(a); Error in Test3 (line 3) c = intOrfloat(a, b)

4   Fail
a = int16(100); b = int16(200); c = intOrfloat(a, b) assert(isequal(c,-100))

Error using * Integers can only be combined with integers of the same class, or scalar doubles. Error in intOrfloat (line 3) a + b - 2*b*isinteger(a); Error in Test4 (line 3) c = intOrfloat(a, b)

5   Pass
a = single(100); b = single(200); c = intOrfloat(a, b) assert(isequal(c,300))

c = single 300