FloatToTextFmt - C++ Builder

C++ Builder 参考手册 ➙ System::Sysutils ➙ FloatToTextFmt


字符串转为字符串,按照参数给定的格式

头文件:#include
命名空间:System::Sysutils
函数原型:

int __fastcall FloatToTextFmt(
    char * Buf,
    const void *Value,
    TFloatValue ValueType,
    char * Format);
int __fastcall FloatToTextFmt(
    char * Buf,
    const void *Value,
    TFloatValue ValueType,
    char * Format,
    const TFormatSettings &AFormatSettings);
int __fastcall FloatToTextFmt(
    System::WideChar * Buf,
    const void *Value,
    TFloatValue ValueType,
    System::WideChar * Format);
int __fastcall FloatToTextFmt(
    System::WideChar * Buf,
    const void *Value,
    TFloatValue ValueType,
    System::WideChar * Format,
    const TFormatSettings &AFormatSettings);

参数:

  • Buf:用于返回生成的字符串;
  • Value:需要分解的浮点数,System::Currency 或者 System::Extended 类型的变量地址;
  • ValueType:指定参数 Value 的类型:
    • fvExtended:参数 Value 是 System::Extended 类型的;
    • fvCurrency:参数 Value 是 System::Currency 类型的;
  • Format:浮点数格式:请参考 FormatFloat 的格式说明;
  • AFormatSettings:地区格式;请参考 请参考 FloatToStrF 的地区格式说明;

返回值:

  • 函数返回生成的字符串的长度,生成的字符串通过参数 BufferArg 返回,
    • 文档并没有说明 BufferArg 具体需要的字节数,在调用函数之前必须已经分配足够的内存,可以根据参数估计或分配多一点内存 (比如 100 个字符长度);
    • 通过参数 BufferArg 返回的字符串没有结束符,根据源码的使用情况分析,这个函数用于连续输出字符到缓存,这样做可以提高效率,不要忘记在使用生成的字符串之前要在字符串长度位置加一个结束符;
  • char * 类型的 BufferArg 参数的函数为过时的 ANSI 版本的函数,直接使用时可能有警告或报错,已经移动到 System.AnsiStrings.hpp 头文件里面了;
  • 没有 AFormatSettings 参数的函数不是线程安全的,因为使用了全局变量作为地区格式;带有 AFormatSettings 参数的函数是线程安全的。

相关:

  • System::Sysutils::FloatToStr
  • System::Sysutils::FloatToStrF
  • System::Sysutils::FloatToText
  • System::Sysutils::FloatToTextFmt
  • System::Sysutils::FloatToDecimal
  • System::Sysutils::FloatToCurr
  • System::Sysutils::TryFloatToCurr
  • System::Sysutils::TextToFloat
  • System::Sysutils::StrToFloat
  • System::Sysutils::StrToFloatDef
  • System::Sysutils::TryStrToFloat
  • System::Sysutils::StrToCurr
  • System::Sysutils::StrToCurrDef
  • System::Sysutils::TryStrToCurr
  • System::Sysutils::CurrToStr
  • System::Sysutils::CurrToStrF
  • System::Sysutils::FormatFloat
  • System::Sysutils::FormatCurr
  • System::Sysutils::TFloatRec
  • System::Sysutils::TFloatValue
  • System::Sysutils::FormatSettings
  • System::Sysutils::TFormatSettings
  • System::Sysutils::StrToBool
  • System::Sysutils::StrToBoolDef
  • System::Sysutils::TryStrToBool
  • System::Sysutils::BoolToStr
  • System::Sysutils::DateTimeToStr
  • System::Sysutils::DateTimeToString
  • System::Sysutils::DateToStr
  • System::Sysutils::GUIDToString
  • System::Sysutils::IntToStr
  • System::Sysutils::IntToHex
  • System::Sysutils::TimeToStr
  • System::Sysutils::UIntToStr
  • System::Sysutils
  • System::Currency
  • System
  • std::itoa, std::_itoa, std::_itot, std::_itow
  • std::ltoa, std::_ltoa, std::_ltot, std::_ltow
  • std::ultoa, std::_ultoa, std::_ultot, std::_ultow
  • std::_i64toa, std::_i64tot, std::_i64tow
  • std::_ui64toa, std::_ui64tot, std::_ui64tow
  • std::ecvt, std::_ecvt
  • std::fcvt, std::_fcvt
  • std::gcvt, std::_gcvt

C++ Builder 参考手册 ➙ System::Sysutils ➙ FloatToTextFmt

你可能感兴趣的:(FloatToTextFmt - C++ Builder)