std::atoll
からcstdlib
までは、文字列をgccでint64_t
に変換しています。この機能はWindowsツールチェーン(Visual Studio Express 2010を使用)では使用できないようです。何が最良の選択肢ですか?std :: atoll with VC++
strings
からuint64_t
への変換にも興味があります。整数定義はcstdint
から取られました。
std::atoll
からcstdlib
までは、文字列をgccでint64_t
に変換しています。この機能はWindowsツールチェーン(Visual Studio Express 2010を使用)では使用できないようです。何が最良の選択肢ですか?std :: atoll with VC++
strings
からuint64_t
への変換にも興味があります。整数定義はcstdint
から取られました。
MSVCは_atoi64と同様の機能を持って、符号なしの64ビットタイプではhere
を参照してください、_strtoui64
使用stringstreams(<sstream>
)
std::string numStr = "12344444423223";
std::istringstream iss(numStr);
long long num;
iss>>num;
利用ブーストのlexical_cast(boost/lexical_cast.hpp
)
std::string numStr = "12344444423223";
long long num = boost::lexical_cast<long long>(numStr);
あなたは、パフォーマンス・テストを実行すると、変換があなたであると結論している場合ボトルネックがあり、本当に速く実行する必要があります。準備機能はありません。あなたは自分で書く。 ここでは、本当に高速でエラーチェックがなく、正の数しか扱わないサンプルがあります。
long long convert(const char* s)
{
long long ret = 0;
while(s != NULL)
{
ret*=10; //you can get perverted and write ret = (ret << 3) + (ret << 1)
ret += *s++ - '0';
}
return ret;
}
Armen、ありがとう。これは、ダブルスのためのhttp://stackoverflow.com/questions/5830868/c-stringstream-is-too-slow-how-to-speed-upに非常によく似ています。 – Cookie
のVisual Studio 2013が最終的にstd::atoll
を持って参照してください。
この問題はVS2013で修正されているようですhttp://connect.microsoft.com/VisualStudio/feedback/details/752386/std-atoll-not-found – javapowered