Does casting to an int after std::floor guarantee the right result?
The range of double is way greater than the range of 32 or 64 bit integers, which is why std::floor returns a double. Casting to int should be fine so long as it’s within the appropriate range – but be aware that a double can’t represent all 64 bit integers exactly, so you may also … Read more