3 ms·
if you have m-bit numbers you can simply loop all of them and find which one when squared is closest to 2. This alogrithm will run in O(1). Alternatively you c
by charcircuit 5y ago
if you have m-bit numbers you can simply loop all of them and find which one when squared is closest to 2. This alogrithm will run in O(1).
Alternatively you can do the same thing with drawing a square and measuring the distance between the center and the corner. Perhaps it's a little cheaty since you have to include a precomputed sprt(2) for the diagonal length of a pixel.