To display 13 digits of pi in MATLAB, you need to use the format long
command, which sets the output format to floating-point numbers with 15 digits of precision. However, since pi itself is only known to 13 digits, setting the format to "long" will display pi to its maximum precision:
main.m15 chars3 lines
This will display the value of pi with up to 15 digits of precision, which is 3.141592653589793. Note that the last two digits are already rounded off. If you want to display pi with exactly 13 digits of precision, you can use fprintf
command with format specifier %.13f
:
main.m23 chars2 lines
This will display pi with exactly 13 digits of precision: 3.1415926535898. Note that the last digit is rounded off.
gistlibby LogSnag