zoukankan      html  css  js  c++  java
  • FormatFloat

    http://www.delphibasics.co.uk/RTL.asp?Name=FormatFloat

    1  function FormatFloat ( const Formatting : string; Value : Extended ) : string;
    2  function FormatFloat ( const Formatting : string; Value : Extended; FormatSettings : TFormatSettings ) : string;
     
    Description
    The FormatFloat function provides rich Formatting of a floating point number Value into a string. 
     
    The Formatting string may contain a mix of freeform text and control characters: 
     
      : Forces digit display or 0
    : Optional digit display
    : Forces display of thousands
    : Forces display of decimals
    E+  : Forces signed exponent display
    E-  : Optional sign exponent display
    : Separator of +ve and -ve and zero values

     
    These are best understood by looking at the sample code. 
     
    Version 2 of this function is for use within threads. You furnish the FormatSettings record before invoking the call. It takes a local copy of global formatting variables that make the routine thread safe.
     
    Related commands
    CurrencyDecimals   Defines decimal digit count in the Format function
    CurrencyFormat   Defines currency string placement in curr display functions
    CurrencyString   The currency string used in currency display functions
    DecimalSeparator   The character used to display the decimal point
    FloatToStrF   Convert a floating point value to a string with formatting
    Format   Rich formatting of numbers and text into a string
    FormatCurr   Rich formatting of a currency value into a string
    FormatDateTime   Rich formatting of a TDateTime variable into a string
    NegCurrFormat   Defines negative amount formatting in currency displays
    StrToFloat   Convert a number string into a floating point value
    ThousandSeparator   The character used to display the thousands separator
     Download this web site as a Windows program.
     
    Example code : Showing all of the formatting data types
    var
      float : extended;

    begin
      // Set up our floating point number
      float := 1234.567;

      // Display a sample value using all of the format options

      // Round out the decimal value
      ShowMessage('##### : '+FormatFloat('#####', float));
      ShowMessage('00000 : '+FormatFloat('00000', float));
      ShowMessage('0     : '+FormatFloat('0'    , float));
      ShowMessage('#,##0 : '+FormatFloat('#,##0', float));
      ShowMessage(',0    : '+FormatFloat(',0'   , float));
      ShowMessage('');

      // Include the decimal value
      ShowMessage('0.#### : '+FormatFloat('0.####', float));
      ShowMessage('0.0000 : '+FormatFloat('0.0000', float));
      ShowMessage('');

      // Scientific format
      ShowMessage('0.0000000E+00 : '+FormatFloat('0.0000000E+00', float));
      ShowMessage('0.0000000E-00 : '+FormatFloat('0.0000000E-00', float));
      ShowMessage('#.#######E-## : '+FormatFloat('#.#######E-##', float));
      ShowMessage('');

      // Include freeform text
      ShowMessage('"Value = "0.0 : '+FormatFloat('"Value = "0.0', float));
      ShowMessage('');

      // Different formatting for negative numbers
      ShowMessage('0.0 : '+FormatFloat('0.0'              , -1234.567));
      ShowMessage('0.0 "CR";0.0 "DB" : '+
                  FormatFloat('0.0 "CR";0.0 "DB"', -1234.567));
      ShowMessage('0.0 "CR";0.0 "DB" : '+
                  FormatFloat('0.0 "CR";0.0 "DB"',  1234.567));
      ShowMessage('');

      // Different format for zero value
      ShowMessage('0.0 : '+FormatFloat('0.0' , 0.0));
      ShowMessage('0.0;-0.0;"Nothing" : '+
                  FormatFloat('0.0;-0.0;"Nothing"', 0.0));
    end;
    Show full unit code
       ##### : 1235
       00000 : 01235
       0     : 1235
       #,##0 : 1,235
       ,0    : 1,235
       
       0.#### : 1234.567
       0.0000 : 1234.5670
       
       0.0000000E+00 : 1.2345670E+03
       0.0000000E-00 : 1.2345670E03
       #.#######E-## : 1.234567E3
       
       "Value = " : Value = 1234.6
       
       0.0 : -1234.6
       0.0 "CR";0.0 "DB" : 1234.6 DB
       0.0 "CR";0.0 "DB" : 1234.6 CR
       
       0.0 : 0.0
       0.0;-0.0;"Nothing" : Nothing
     
  • 相关阅读:
    使用vue-cli4 F5刷新 报错:Uncaught SyntaxError: Unexpected token <
    visual stuido 删除虚拟目录
    visual studio2017 使用内联变量 编译失败 但不显示错误信息
    spring boot 整合CXF创建web service
    .net 解析以竖线,美元符等分割符分割的字符串为实体
    c# 动态构造实体属性的lambda Expression表达式
    spring boot 创建web service及调用
    JPA使用log4jdbc输出sql日志
    JPA 使用log4j2输出SQL日志到文件
    JPA 使用logback输出SQL日志到文件
  • 原文地址:https://www.cnblogs.com/findumars/p/3496103.html
Copyright © 2011-2022 走看看