Home > atmlab > arts > xml > xmlGetPrecisionFormatString.m

xmlGetPrecisionFormatString

PURPOSE ^

Returns the proper format string for the given precision.

SYNOPSIS ^

function format = xmlGetPrecisionFormatString(precision)

DESCRIPTION ^

 Returns the proper format string for the given precision.

    Precision could be either the number of digits or a string of value
    FLOAT or DOUBLE

 FORMAT   format = xmlGetPrecisionFormatString(precision)

 OUT   format     Format string for printf
 IN    precision  Digits

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlGetPrecisionFormatString.m

SOURCE CODE ^

0001 % Returns the proper format string for the given precision.
0002 %
0003 %    Precision could be either the number of digits or a string of value
0004 %    FLOAT or DOUBLE
0005 %
0006 % FORMAT   format = xmlGetPrecisionFormatString(precision)
0007 %
0008 % OUT   format     Format string for printf
0009 % IN    precision  Digits
0010 
0011 % 2004-03-08  Created by Oliver Lemke.
0012 
0013 function format = xmlGetPrecisionFormatString(precision)
0014 
0015 if (strcmpi (precision, 'FLOAT'))
0016   precision = 7;
0017 elseif (strcmpi (precision, 'DOUBLE'))
0018   precision = 15;
0019 else
0020   error('Invalid precision: %s', precision);
0021 end
0022 
0023 format = sprintf ('%%1.%de', precision);
0024

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005