I noticed a difference with round() at 15 decimal places, and I need to know why this is so.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mara Gati
el 16 de Abr. de 2016
Comentada: Jan
el 16 de Abr. de 2016
Yesterday, I noticed that
round(2.4999999999999999) %15 decimal places
ans =
3
But
round(2.499999999999999) %16 decimal places
ans =
2
This can be for any number, not just 2. Does anybody know what causes this?
1 comentario
Jan
el 16 de Abr. de 2016
The first example has 16 digits and the 2nd one 15 digits, not the other way around.
Respuesta aceptada
Mara Gati
el 16 de Abr. de 2016
1 comentario
John D'Errico
el 16 de Abr. de 2016
It is not 15 decimal digits that matters, since doubles are not stored in decimal form. A double in MATLAB is actually stored in binary. So 52 binary bits represents something a little more accurate than 15 decimal digits.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!