Change directory structure
This commit is contained in:
43
luprex/misc/bigid.cpp
Normal file
43
luprex/misc/bigid.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
|
||||
bool storable(int64_t n) {
|
||||
double d = n;
|
||||
int64_t n1 = int64_t(d);
|
||||
return n1 == n;
|
||||
}
|
||||
|
||||
|
||||
// Find the biggest number where the number is storable,
|
||||
// and all numbers smaller are also storable.
|
||||
int64_t find_biggest() {
|
||||
int64_t v = 256;
|
||||
int64_t best = 256;
|
||||
while (true) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (!storable(v - i)) {
|
||||
return best;
|
||||
}
|
||||
}
|
||||
best = v;
|
||||
v <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int64_t best = find_biggest();
|
||||
|
||||
printf("%016lx ", best);
|
||||
for (int i = -12; i <= 12; i++) {
|
||||
if (i == 0) printf(" ");
|
||||
if (storable(best + i)) {
|
||||
printf("* ");
|
||||
} else {
|
||||
printf("- ");
|
||||
}
|
||||
if (i == 0) printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user