floating point - Precision of Fortran vs that of Matlab -


in fortran, output result of tanh(1) , value 0.7615941763:

open(unit=2, file='test_digits.txt', action="write") write(2, '(1000f14.10)')( real(tanh(1.0))) 

however, try same in matlab , output 0.761594155955765. there difference @ 8th digit.

what reason precision-difference? can fix somehow?

matlab using double precision default, using single precision floats! limited 7-8 digits... if use double precision well, same precision:

program test   write(*,*) 'single precision:', tanh(1.0)   write(*,*) 'double precision:', tanh(1.0d0) end program 

output:

 single precision:  0.761594176      double precision:  0.76159415595576485   

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -