Computation's with large numbers.

8 vues (au cours des 30 derniers jours)
Yuechuan Chen
Yuechuan Chen le 9 Déc 2019
Commenté : Yuechuan Chen le 9 Déc 2019
So, I'm trying to divide n-1( n=94315998522576010519588224930693232398146802027362761139521) by 2^143, I stored n has a symbolic variable to not lose precision, so:
n=sym('94315998522576010519588224930693232398146802027362761139521');
however, when I do n-1/2^143 it gives me a stupid answer 1051658525598479156308916018992636883668880484184809306202701679900748001639266703538773119682234810367/11150372599265311570767859136324180752990208 (the correct answer should be 8458551289020639 ) .
It seems like Matlab has treated n-1/2^143 as a string rather than a computation because it's outputing the / sign.
I've also tried vpa but I encountered the same problem.
Could someone shed a light on this please, how can I compute this without losing accuracy, i.e. preventing Matlab rounding n and my answer.
THANKS!

Réponse acceptée

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 9 Déc 2019
n=sym('94315998522576010519588224930693232398146802027362761139521');
answer=vpa((n-1)/2^143)
  1 commentaire
Yuechuan Chen
Yuechuan Chen le 9 Déc 2019
Perfect! Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by