Format of a number
6 views (last 30 days)
Show older comments
Sania Nizamani
on 3 Feb 2024
Edited: Walter Roberson
on 29 Feb 2024
How can write or convert the following number as 6.5192e-353 in MATLAB R2020a?
0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006519189212084746229776610798014015843782113571066818006946457413769773297894931346117308775461249994927327158400893029327734069232681151773609865266731521520054375903565338010423727080339452649084922482509849273285567974490982577103240751064484991178667240948437033727548535692375294238872288406967117777615757244524019518397825957547275970242462715854779648975320964429805929292231364557099949366197615233659670288768272563638001796519438847757405012852185872992289542013224335055773245806454313412733757091902202174306446270378638302539811037703945271596412702870934289523078309661834975228374662651691916691844575389604650486112874690677474198715593749538378138098722106119539312955520393459310616851829420920453027031099134852992191414078925320755874886661755203134433583041067365856197990407535151294849597815149662533367217765732422274124039425622331728003788521934226574093175659329930102209493669914675156094756791723604103890639375296094056543847670814774909966692607698458476102455720781979
Thanks in advance!
3 Comments
Accepted Answer
John D'Errico
on 3 Feb 2024
Moved: John D'Errico
on 29 Feb 2024
You need to understand that MATLAB can represent numbers as large as
realmax
and as small in magnitude as
realmin
as double precision numbers. Actually, it can go a little smaller than that, because of something called de-normalized numbers, but that is an aside that I won't go into. Regardless, the number you have there is too small by a large amount. It underflows to ZERO. As far as MATLAB is concerned, it does not exist as a double.
However, if you have created it, then you are using symbolic tools to create it. And symbolic floats can handle that with nary a problem. As such, if you have the number...
x = sym('0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006519189212084746229776610798014015843782113571066818006946457413769773297894931346117308775461249994927327158400893029327734069232681151773609865266731521520054375903565338010423727080339452649084922482509849273285567974490982577103240751064484991178667240948437033727548535692375294238872288406967117777615757244524019518397825957547275970242462715854779648975320964429805929292231364557099949366197615233659670288768272563638001796519438847757405012852185872992289542013224335055773245806454313412733757091902202174306446270378638302539811037703945271596412702870934289523078309661834975228374662651691916691844575389604650486112874690677474198715593749538378138098722106119539312955520393459310616851829420920453027031099134852992191414078925320755874886661755203134433583041067365856197990407535151294849597815149662533367217765732422274124039425622331728003788521934226574093175659329930102209493669914675156094756791723604103890639375296094056543847670814774909966692607698458476102455720781979')
As you can see, MATLAB has no problem expressing it as you ask. And if you want to see only 5 significant digits, then tell vpa to do so.
vpa(x,5)
So just learn to use vpa.
2 Comments
More Answers (0)
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!