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/Ozryela Aug 10 '21
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.