Cody

Problem 43283. Subtract integers and add doubles

Solution 3314248

Submitted on 21 Oct 2020
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))

Matrix dimensions must agree. Error in intOrfloat (line 2) if isinteger(class(a)==('float'|'double') || class(b)==('float'|'double')) Error in Test1 (line 3) c = intOrfloat(a, b)

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

Matrix dimensions must agree. Error in intOrfloat (line 2) if isinteger(class(a)==('float'|'double') || class(b)==('float'|'double')) Error in Test2 (line 3) c = intOrfloat(a, b)

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

Matrix dimensions must agree. Error in intOrfloat (line 2) if isinteger(class(a)==('float'|'double') || class(b)==('float'|'double')) 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))

Matrix dimensions must agree. Error in intOrfloat (line 2) if isinteger(class(a)==('float'|'double') || class(b)==('float'|'double')) Error in Test4 (line 3) c = intOrfloat(a, b)

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

Matrix dimensions must agree. Error in intOrfloat (line 2) if isinteger(class(a)==('float'|'double') || class(b)==('float'|'double')) Error in Test5 (line 3) c = intOrfloat(a, b)

Suggested Problems

More from this Author15

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!