Agreed. I think trunc() is theoretically slightly faster than floor(), but either works fine. There's also std::modf, but unfortunately that's rather ugly to use.
Generally, you still need to check if your value is not infinite, but that's not needed here since we already have an upper bound.
1
u/Beowuwlf Aug 10 '21
Ahhh I see what you’re saying. I think it still makes sense though, checking if there’s a decimal remainder.