Add double constructor for Version

This commit is contained in:
Georg Hagen
2025-06-11 17:06:20 +02:00
parent 6d49c7199f
commit 3b243260c0
2 changed files with 18 additions and 0 deletions

View File

@@ -178,4 +178,20 @@ namespace OpenVulkano
return CompareTimestamp(other);
}
//endregion
namespace
{
uint32_t GetDigits(double val)
{
if (val == 0) return 0;
std::string fracStr = std::to_string(val);
fracStr.erase(fracStr.find_last_not_of('0') + 1, std::string::npos);
fracStr.erase(0, fracStr.find_first_of('.') + 1);
return std::stoul(fracStr);
}
}
Version::Version(double version)
: Version(static_cast<uint32_t>(version), GetDigits(version))
{}
}