Cody

# Problem 371. Decimal Comparison

Solution 2094965

Submitted on 16 Jan 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   Pass
assert(numCmp('12.3456',12.3456))

lengths1 = 2 4

2   Fail
assert(numCmp('12.3456',12.3456789))

lengths1 = 2 4

Assertion failed.

3   Fail
assert(~numCmp('12.3456',12.345))

lengths1 = 2 4

Matrix dimensions must agree. Error in numCmp (line 5) tf = all(s1 == (s2(1:min(sum(lengths1)+1, numel(s2))))); Error in Test3 (line 1) assert(~numCmp('12.3456',12.345))

4   Fail
assert(~numCmp('12.34567890',12.3456))

lengths1 = 2 8

Matrix dimensions must agree. Error in numCmp (line 5) tf = all(s1 == (s2(1:min(sum(lengths1)+1, numel(s2))))); Error in Test4 (line 1) assert(~numCmp('12.34567890',12.3456))

5   Fail
assert(numCmp('12e6',12e6))

lengths1 = 4

Unrecognized function or variable 'n1'. Error in numCmp (line 7) tf = str2num(n1) == n2; Error in Test5 (line 1) assert(numCmp('12e6',12e6))

6   Fail
assert(~numCmp('54',100))

lengths1 = 2

Unrecognized function or variable 'n1'. Error in numCmp (line 7) tf = str2num(n1) == n2; Error in Test6 (line 1) assert(~numCmp('54',100))