% printing.m
% Show some things about printing.
%
%  An assignment statement without a semicolon prints numbers
%  in a default format.
%
format short
s = 0.000001234567890987654321
m = 12345.67890987654321
b = 1234567890987654.321
%
%  The default format is "short".  Asking for "long" means more digits
%  appear in real numbers.
%
format long
s = 0.000001234567890987654321
m = 12345.67890987654321
b = 1234567890987654.321
%
%  FPRINTF has three formats for real numbers: %e, %f, %g
%
fprintf ( '\n' );
fprintf ( '  E: s = %e\n', s );
fprintf ( '  F: s = %f\n', s );
fprintf ( '  G: s = %g\n', s );

fprintf ( '\n' );
fprintf ( '  E: m = %e\n', m );
fprintf ( '  F: m = %f\n', m );
fprintf ( '  G: m = %g\n', m );

fprintf ( '\n' );
fprintf ( '  E: b = %e\n', b );
fprintf ( '  F: b = %f\n', b );
fprintf ( '  G: b = %g\n', b );
%
%  You can control the number of spaces used in printout.
%
fprintf ( '\n' );
fprintf ( '   4F: m = %4f\n', m );
fprintf ( '  10F: m = %10f\n', m );
fprintf ( '  20F: m = %20f\n', m );
%
%  You can control the number of decimal places used in printout.
%
fprintf ( '\n' );
fprintf ( '  20.1F:  m = %20.1f\n', m );
fprintf ( '  20.5F:  m = %20.5f\n', m );
fprintf ( '  20.16F: m = %20.16f\n', m );
%
%  The %d format is used to print integers.
%  It can also be used to print just the integer part of a real number.
%
i = 12345

fprintf ( '\n' );
fprintf ( '    D: i = %d\n', i2 );
fprintf ( '  10D: i = %10d\n', i2 );

