inline constexpr auto zero_to_one = []<std::floating_point T>(const T x) noexcept {
static_assert(sizeof(T) <= 8);
using U = std::conditional_t<sizeof(T) == 4, int, long long>;
constexpr auto one = std::bit_cast<U>(T(1));
return std::bit_cast<T>(-U(T(0) < x) & (one ^ ((std::bit_cast<U>(x) ^ one) & -U(x < T(1)))));
};
C++だけで書くならこれが最速ではないでしょうか。
別の案があればコメントで教えてください。