I've been working with C++ and have been utilizing the UBA sanitizer to convert a double to an unsigned long long. However, I've been encountering an issue when the value is negative, which results in the error message: "runtime error: value -2 is outside the range of representable values of type 'long long unsigned int'"
The code is something like this:
unsigned long long valueULL = 0;
double value = -2;
valueULL = (unsigned long long)value;
I tried to use this cast instead and it doesn't help:
valueULL = std::make_unsigned_t<unsigned long long>(value);
Is there a way to cast it without encountering this error?