Add more array helper functions, add U64 to I64 saturate cast
This commit is contained in:
+7
-4
@@ -585,16 +585,19 @@ DQN_API uint64_t Dqn_Safe_SaturateCastUSizeToU64(Dqn_usize val)
|
||||
return result;
|
||||
}
|
||||
|
||||
// NOTE: Dqn_Safe_SaturateCastU64To*
|
||||
// -----------------------------------------------------------------------------
|
||||
// INT*_MAX literals will be promoted to the type of val as val is
|
||||
// the highest possible rank (unsigned > signed).
|
||||
// NOTE: Dqn_Safe_SaturateCastU64To* ///////////////////////////////////////////////////////////////
|
||||
DQN_API int Dqn_Safe_SaturateCastU64ToInt(uint64_t val)
|
||||
{
|
||||
int result = DQN_CHECK(val <= INT_MAX) ? DQN_CAST(int)val : INT_MAX;
|
||||
return result;
|
||||
}
|
||||
|
||||
DQN_API int64_t Dqn_Safe_SaturateCastU64ToI64(uint64_t val)
|
||||
{
|
||||
int64_t result = DQN_CHECK(val <= INT64_MAX) ? DQN_CAST(int64_t)val : INT64_MAX;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Both operands are unsigned and the lowest rank operand will be promoted to
|
||||
// match the highest rank operand.
|
||||
DQN_API unsigned int Dqn_Safe_SaturateCastU64ToUInt(uint64_t val)
|
||||
|
||||
Reference in New Issue
Block a user