work with numbers in number
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lev Mihailov
el 19 de Nov. de 2019
Respondida: Walter Roberson
el 19 de Nov. de 2019
Hello! I have the number 40.201109, I need to work with numbers 109, and then with 110 and at the end of 40. Help me how to separate them
6 comentarios
Walter Roberson
el 19 de Nov. de 2019
You do not understand how you get that number.
If you have a number of the form AB.cdefgh then how should the output be formed?
Respuesta aceptada
Walter Roberson
el 19 de Nov. de 2019
x = 40.201109;
xs = sprintf('%.6f', x);
a = str2double(xs(1:2));
b = str2double(xs(end-3:end-1));
c = str2double(xs(end-2:end));
This presumes there are exactly 6 significant decimal places. It is not generally possible to figure out how many significant decimal places a binary floating point number has -- for example 40.201109 is stored internally as 40.201109000000002424712874926626682281494140625 exactly.
0 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!