Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Derivation of the 0x9E3779B97F4A7C17u constant
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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; }
clang++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion