Created
October 3, 2016 09:31
-
-
Save coralmw/ddfba51983200cd339c0250179b2b019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cfloat> | |
#include <cmath> | |
#include <cstdint> | |
#include <iostream> | |
int main(void){ | |
float f; | |
uint64_t correct = 0; | |
uint64_t tried = 0; | |
for (f=0.0f; f<INFINITY; f = nextafterf(f, INFINITY)) { | |
tried++; | |
if (log(exp(f)) == f) correct++; | |
if (tried % 10000 == 0) std::cout << std::string(20,'\b') << (double)tried/pow(2, 31); | |
} | |
std::cout << "\ncorrect: " << (double)correct/(double)tried * 100.0 << "%" << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment