I need high precision for a project I'm working on. The problem I have is illustrated here when substracting:

>> 1-0.9999999999999999

ans = 1.1102e-16

>> 1-0.99999999999999999

ans = 0

I know it's related to the double precision. Is there anyway I could get a higher precision? I checked the "vpa" function but I can't manage to get higher precision. Could someone help me with this?

Thank you in advance!

  • Do you have an installation of Matlab's Symbolic Math Toolbox ? Oct 20, 2014 at 16:03
  • 5
    Try vpa('1-0.9999999999999999') (note quotation marks). vpa(1-0.9999999999999999) won't work because 0.9999999999999999 is first converted to double
    – Luis Mendo
    Oct 20, 2014 at 16:06
  • Minor note: vpa requires the Symbolic Math Toolbox, which High Performance Mark is inevitably referring to in the end. Also good job Luis!
    – rayryeng
    Oct 20, 2014 at 16:18
  • There are other languages that provide arbitrary precision accuracy, like python.
    – serigado
    Oct 20, 2014 at 19:02
  • 2
    @AnonSubmitter85: unfortunately, long double's are not necessarily portable, VC++ maps long double to simply double: msdn.microsoft.com/en-us/library/9cx8xs15.aspx. Although in reality double computations are performed in 80-bit registers if done on the FPU (the native format of x87), but they are stored in 64-bit when transferred to memory. There is an instruction that affects whether intermediate results are reduced to 64-bit after each computation.
    – Amro
    Oct 21, 2014 at 8:58

1 Answer 1


Matlab internally uses the 64-bit system double for all its numbers, which explains the precision issues. There do exist extensions for matlab that allow you to use arbitrary precision arithmetic. See for example this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.