The solution which I presented just now works perfectly fine on the live editor of Matlab, but don't know why math works still say it is incorrect?
use fix instead of floor or ceil command
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
x = -8.8;
y_correct = -8;
assert(isequal(round_zero(x),y_correct))
x =
-8
|
2 | Fail |
x = 8.8;
y_correct = 8;
assert(isequal(round_zero(x),y_correct))
x =
8
|
3 | Fail |
x = 0.8;
y_correct = 0;
assert(isequal(round_zero(x),y_correct))
x =
0
|
4 | Fail |
x = 0.4;
y_correct = 0;
assert(isequal(round_zero(x),y_correct))
x =
0
|
5 | Fail |
x = 0;
y_correct = 0;
assert(isequal(round_zero(x),y_correct))
x =
0
|
6 | Fail |
x = eps;
y_correct = 0;
assert(isequal(round_zero(x),y_correct))
x =
0
|
7 | Fail |
x = pi;
y_correct = 3;
assert(isequal(round_zero(x),y_correct))
x =
3
|
Project Euler: Problem 9, Pythagorean numbers
282 Solvers
367 Solvers
Create an n-by-n null matrix and fill with ones certain positions
269 Solvers
5113 Solvers
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
358 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!