writeln(pi);
writeln(pi:0);
的结果是:
 3.1415926536E+00
 3.1E+00
第一个结果不知为何会空格
第二个结果除了空格之外,也不知道为什么会是3.1E+00这个结果。

解决方案 »

  1.   

    这确实是一个奇怪的问题,我试验了一下freepascal也一样,参考free pascal的资料,在Free Pascal :
    Reference guide. 有如下说明Write
    Declaration: Procedure Write ([Var F : Any filetype;] V1 [; V2; ... , Vn)];
    Description: Write writes the contents of the variables V1, V2 etc. to the file F. F can be a typed file, or a Text
    file. If F is a typed file, then the variables V1, V2 etc. must be of the same type as the type in the
    declaration of F. Untyped files are not allowed. If the parameter F is omitted, standard output is assumed.
    If F is of type Text, then the necessary conversions are done such that the output of the variables
    is in human-readable format. This conversion is done for all numerical types. Strings are printed
    exactly as they are in memory, as well as PChar types. The format of the numerical conversions
    can be influenced through the following modifiers: OutputVariable : NumChars [:
    Decimals ] This will print the value of OutputVariable with a minimum of NumChars
    characters, from which Decimals are reserved for the decimals. If the number cannot be represented
    with NumChars characters, NumChars will be increased, until the representation fits. If the
    representation requires less than NumChars characters then the output is filled up with spaces, to
    the left of the generated string, thus resulting in a right-aligned representation. If no formatting is
    specified, then the number is written using its natural length, with nothing in front of it if it’s positive,
    and a minus sign if it’s negative. Real numbers are, by default, written in scientific notation.
    Errors: If an error occurs, a run-time error is generated. This behavior can be controlled with the {$i}
    switch.
    See also: WriteLn (181), Read (164), Readln (165), Blockwrite (121)
      

  2.   

    The format of the numerical conversions
    can be influenced through the following modifiers: OutputVariable : NumChars [:
    Decimals ] This will print the value of OutputVariable with a minimum of NumChars
    characters, from which Decimals are reserved for the decimals. If the number cannot be represented
    with NumChars characters, NumChars will be increased, until the representation fits. 这个提到截断的问题