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!
vpa('1-0.9999999999999999')
(note quotation marks).vpa(1-0.9999999999999999)
won't work because0.9999999999999999
is first converted todouble
vpa
requires the Symbolic Math Toolbox, which High Performance Mark is inevitably referring to in the end. Also good job Luis!long double
's are not necessarily portable, VC++ mapslong double
to simplydouble
: msdn.microsoft.com/en-us/library/9cx8xs15.aspx. Although in realitydouble
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.