Why the answer is 10.
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Why the answer is 10. Shouldn't it be 11?
format long;
y = (3.8 - 1.6)/0.2;
x = floor(y);
disp(x);
1 comentario
Arif Hoq
el 30 de En. de 2022
Editada: Arif Hoq
el 30 de En. de 2022
>> (3.8 - 1.6)/0.2
ans =
10.999999999999998
Floor rounds each element of a vector/matrix to the nearest integer less than or equal to that element. so the floor value of y would be 10.
If you use "round" function it will show the value 11.
format long;
y = (3.8 - 1.6)/0.2;
x = round(y);
disp(x);
for more information please type in the command prompt.
doc round
doc floor
Ver también
Categorías
Más información sobre NaNs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!