C++ Builder 參考手冊(cè) ? System::Sysutils ? StrToInt64Def
字符串轉(zhuǎn)64位整數(shù)值
頭文件:#include <System.SysUtils.hpp>
命名空間:System::Sysutils
函數(shù)原型:
__int64 __fastcall StrToInt64Def(const System::UnicodeString S, const __int64 Default);
參數(shù):
- S:字符串;
- Default:默認(rèn)值;
返回值:
- 整數(shù)類型數(shù)值屏积,如果轉(zhuǎn)換失敗,函數(shù)返回參數(shù) Default 的值;
- 字符串可以是十進(jìn)制或十六進(jìn)制數(shù)據(jù):開始可以有正負(fù)號(hào) "+" 或 "-"共耍,也可以沒有谆沃,然后是數(shù)字:
數(shù)字以 "0x" 開頭認(rèn)為是十六進(jìn)制數(shù)據(jù),否則認(rèn)為是十進(jìn)制介袜,不支持八進(jìn)制及其他進(jìn)制甫何; - 函數(shù) StrToInt64、StrToInt64Def 和 TryStrToInt64 的區(qū)別:
? StrToInt64 轉(zhuǎn)換失敗拋出異常遇伞;
? StrToInt64Def 轉(zhuǎn)換失敗返回默認(rèn)值辙喂;
? TryStrToInt64 轉(zhuǎn)換結(jié)果通過參數(shù)返回,函數(shù)返回值返回是否轉(zhuǎn)換成功鸠珠。
例:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Lines->Add(StrToInt64Def(L"9876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"09876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"0x9876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"-9876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"-09876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"-0x9876543210", 0));
Memo1->Lines->Add(StrToInt64Def(L"0x6789ABCDEF", 0));
Memo1->Lines->Add(StrToInt64Def(L"0x789ABCDEFH", 0));
}
運(yùn)行結(jié)果:由于最后一個(gè)含有字母 'H'巍耗,轉(zhuǎn)換失敗,返回默認(rèn)值0渐排,其他的都轉(zhuǎn)換成功
相關(guān):
- System::Sysutils::IntToStr
- System::Sysutils::IntToHex
- System::Sysutils::UIntToStr
- System::Sysutils::Format
- System::Sysutils::FormatBuf
- 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::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 ? StrToInt64Def