C++ Builder 參考手冊(cè) ? System::Sysutils ? TextToFloat
字符串轉(zhuǎn)浮點(diǎn)數(shù)值
頭文件:#include <System.SysUtils.hpp>
命名空間:System::Sysutils
函數(shù)原型:
bool __fastcall TextToFloat(System::WideChar *Buffer, void *Value, TFloatValue ValueType);
bool __fastcall TextToFloat(System::WideChar *Buffer, void *Value, TFloatValue ValueType, const TFormatSettings &AFormatSettings);
bool __fastcall TextToFloat(char *Buffer, void *Value, TFloatValue ValueType);
bool __fastcall TextToFloat(char *Buffer, void *Value, TFloatValue ValueType, const TFormatSettings &AFormatSettings);
bool __fastcall TextToFloat(const System::UnicodeString S, System::Extended &Value);
bool __fastcall TextToFloat(const System::UnicodeString S, System::Extended &Value, const TFormatSettings &AFormatSettings);
bool __fastcall TextToFloat(const System::UnicodeString S, double &Value);
bool __fastcall TextToFloat(const System::UnicodeString S, double &Value, const TFormatSettings &AFormatSettings);
bool __fastcall TextToFloat(const System::UnicodeString S, System::Currency &Value);
bool __fastcall TextToFloat(const System::UnicodeString S, System::Currency &Value, const TFormatSettings &AFormatSettings);
參數(shù):
- Buffer:字符串圾结;
- Value:浮點(diǎn)數(shù)斯撮,輸出轉(zhuǎn)換結(jié)果推穷;
- ValueType:參數(shù) Value 的類型:
? fvExtended:參數(shù) Value 輸出 System::Extended 類型數(shù)值律秃;
? fvCurrency:參數(shù) Value 輸出 System::Currency 類型數(shù)據(jù)俊扭; - AFormatSettings:地區(qū)格式;
返回值:
- true:轉(zhuǎn)換成功翰舌,通過參數(shù) Value 輸出轉(zhuǎn)換之后的浮點(diǎn)類型數(shù)值束莫;
- false:轉(zhuǎn)換失敗巷懈;
- 如果沒有 AFormatSettings 參數(shù)该抒,小數(shù)點(diǎn)使用全局變量 FormatSettings.DecimalSeparator,
不同國家或地區(qū)的小數(shù)點(diǎn)也不同顶燕,例如:中國和美國使用小圓點(diǎn) '.'凑保,法國和越南使用逗號(hào) ',';
如果 FormatSettings 被修改涌攻,可以用 Sysutils::GetFormatSettings(); 恢復(fù)默認(rèn)值為本地格式欧引; - 如果有 AFormatSettings 參數(shù),小數(shù)點(diǎn)使用 AFormatSettings.DecimalSeparator恳谎;
- 沒有 AFormatSettings 參數(shù)的 CurrToStrF 函數(shù)不是線程安全的芝此,因?yàn)槭褂昧巳肿兞?FormatSettings 作為默認(rèn)的地區(qū)格式;帶有 AFormatSettings 參數(shù)的函數(shù)是線程安全的惠爽;
- 參數(shù) Buffer 為 char * 類型的函數(shù)由于 ANSI 編碼原因視為過時(shí)函數(shù)癌蓖,其他版本的函數(shù)為現(xiàn)在使用的函數(shù)。
相關(guān):
- System::Sysutils::FloatToStr
- System::Sysutils::FloatToStrF
- System::Sysutils::FloatToText
- System::Sysutils::FloatToTextFmt
- System::Sysutils::Format
- System::Sysutils::FormatBuf
- System::Sysutils::FormatFloat
- System::Sysutils::StrToBool
- System::Sysutils::StrToBoolDef
- System::Sysutils::StrToCurr
- System::Sysutils::StrToCurrDef
- System::Sysutils::StrToDate
- System::Sysutils::StrToDateDef
- System::Sysutils::StrToDateTime
- System::Sysutils::StrToDateTimeDef
- System::Sysutils::StrToFloat
- System::Sysutils::StrToFloatDef
- System::Sysutils::StrToInt
- System::Sysutils::StrToIntDef
- System::Sysutils::StrToInt64
- System::Sysutils::StrToInt64Def
- System::Sysutils::StrToTime
- System::Sysutils::StrToTimeDef
- System::Sysutils::StrToUInt
- System::Sysutils::StrToUIntDef
- System::Sysutils::StrToUInt64
- System::Sysutils::StrToUInt64Def
- System::Sysutils::TFloatValue
- System::Sysutils::TimeToStr
- System::Sysutils::TryStrToBool
- System::Sysutils::TryStrToCurr
- System::Sysutils::TryStrToDate
- System::Sysutils::TryStrToDateTime
- System::Sysutils::TryStrToFloat
- System::Sysutils::TryStrToInt
- System::Sysutils::TryStrToInt64
- System::Sysutils::TryStrToTime
- System::Sysutils::TryStrToUInt
- System::Sysutils::TryStrToUInt64
- System::Sysutils
- std::atof, std::_ttof, std::_wtof
- std::_atold, std::_ttold, std::_wtold
- std::atoi, std::_ttoi, std::_wtoi
- std::atol, std::_ttol, std::_wtol
- std::atoll, std::_ttoll, std::_wtoll
- std::_atoi64, std::_ttoi64, std::_wtoi64
- std::strtof, std::_tcstof, std::wcstof
- std::strtod, std::_tcstod, std::wcstod
- std::strtold, std::wcstold, std::_strtold, std::_tcstold, std::_wcstold
- std::strtol, std::_tcstol, std::wcstol
- std::strtoll, std::_tcstoll, std::wcstoll
- std::strtoul, std::_tcstoul, std::wcstoul
- std::strtoull, std::_tcstoull, std::wcstoull
- <cstdlib>
C++ Builder 參考手冊(cè) ? System::Sysutils ? TextToFloat