Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Derivation of the 0x9E3779B97F4A7C17u constant
#include <cmath> #include <cstdint> #include <ios> #include <iostream> std::uint64_t next_odd(const std::uint64_t x) { return (x % 2 == 0) ? x + 1 : x; } int main() { const long double num = std::pow(2.0l, 64.0l); const long double phi = 1.61803398874989484820459l; // (1 + sqrt(5)) / 2 const long double x = num / phi; const std::uint64_t y = next_odd(static_cast<std::uint64_t>(x)); std::cout << "0x" << std::hex << std::uppercase << y << "u" << std::endl; }
run
|
edit
|
history
|
help
0
template specialization inheritance solution
Exploring stringstreams
DESim Example
Reverse polish notation
mine
void pointer
34534
11/29
C++ standard
wasm test for node