how to remove exponential value from a number
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rajashree Annapillai
el 26 de Ag. de 2018
Comentada: Image Analyst
el 23 de Ag. de 2022
If a=4.5236e+15 ,then I want to print the result as b = 4.5236 alone by eliminating the exponential value.How can I do this.Please anyone help me .
Respuesta aceptada
Image Analyst
el 26 de Ag. de 2018
Try this:
a = 4.5236e+15
b = a / 10^floor(log10(a))
fprintf('b = %g\n', b)
3 comentarios
Ajin R.
el 23 de Ag. de 2022
Editada: Ajin R.
el 23 de Ag. de 2022
It works well ! Thanks to Image Analyst. But for negative numbers, it gives complex number as output.
For eg:-
a = -4.5236e+15
b = a / 10^floor(log10(abs(a)))
fprintf('b = %g\n', b)
Output:
b =
3.0227 + 3.3655i
b = 3.02274
a = -4.5236e+15
b = a / 10^floor(log10(abs(a)))
fprintf('b = %g\n', b)
Output:
b =
-4.5237
b = -4.5237
Image Analyst
el 23 de Ag. de 2022
@Ajin R. Not sure what you meant, but the output is not what you said it was. Look:
% First code snippet:
a = -4.5236e+15;
b = a / 10^floor(log10(abs(a)))
fprintf('b = %g\n', b)
% Second code snippet:
a = -4.5236e+15;
b = a / 10^floor(log10(abs(a)))
fprintf('b = %g\n', b)
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!