Cody

# Problem 371. Decimal Comparison

Solution 3172496

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

tf = logical 1

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

tf = logical 0

Assertion failed.

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

Index exceeds the number of array elements (6). Error in numCmp (line 3) tf = strcmp(v(1:length(n1)),n1) Error in Test3 (line 1) assert(~numCmp('12.3456',12.345))

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

Index exceeds the number of array elements (7). Error in numCmp (line 3) tf = strcmp(v(1:length(n1)),n1) Error in Test4 (line 1) assert(~numCmp('12.34567890',12.3456))

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

tf = logical 0

Assertion failed.

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

tf = logical 0

### Community Treasure Hunt

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

Start Hunting!