Could anyone tell me what is wrong with the following code?

1 visualización (últimos 30 días)
Ryan
Ryan el 29 de Jun. de 2020
Comentada: Ryan el 29 de Jun. de 2020
>> a=(6.6-5.5)/0.1
a =
11.0000
>> floor(a)
ans =
10
I suppose I should get ans=11, right? But I got ans=11. If I run the following code, I got the right result
>> a=(2.2-1.1)/0.1
a =
11
>> floor(a)
ans =
11
Could anyone tell me what is wrong with the first part?

Respuesta aceptada

madhan ravi
madhan ravi el 29 de Jun. de 2020
Editada: madhan ravi el 29 de Jun. de 2020
sprintf('%.32f',(6.6-5.5)/0.1)
(6.6-5.5)/sym(0.1)
  1 comentario
Ryan
Ryan el 29 de Jun. de 2020
>> sprintf('%.32f',(6.6-5.5)/sym(1))
ans =
'1.10000000000000008881784197001252'
Now I tried the above code, and I got the wrong result. Is it an inherent flaw in MATLAB, which cannot be fixed completely?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by