logoalt Hacker News

aw1621107today at 5:43 AM1 replyview on HN

std::floor was made constexpr in C++23, which is pretty recent as far as C++ standards go. It's possible the author didn't think using C++23 was worth the constraints it places on who could use the code.


Replies

CodesInChaostoday at 6:21 AM

That's a mathematical expression, not a C++ expression. And floor here isn't the C++ floor function, it's just describing the usual integer division semantics. The challenge here is that you need 128-bit integers to avoid overflowing.

show 1 reply