fpprec:1000000$ b1: bfloat(1) ... 1 ms floor(b1) ... 2 ms ceiling(b1) ... 16480 ms round(b1) ... 24938 ms
I believe an equally accurate solution can be found much more efficiently using
round(rationalize(b1)) ... 7 ms
Actually, the speedup is much smaller in the general case:
fpprec:200000$ b11:1.0b0+1.0b-199999$ round(b11) ... 1276 ms round(rationalize(b11)) ... 279 ms
fpprec:1000000$ b3: 1.0b0/3$ round(b3) ... 32035 ms round(rationalize(b3)) ... 9173 ms
... and for "floor" and "ceiling", the existing method can be faster:
floor(b3) ... 3 ms floor(rationalize(b3)) ... 3288 ms; ceiling(b3) ... 16379 ms ceiling(rationalize(b3)) ... 3318 ms
so this may require some additional analysis.
Log in to post a comment.
Actually, the speedup is much smaller in the general case:
fpprec:200000$
b11:1.0b0+1.0b-199999$
round(b11) ... 1276 ms
round(rationalize(b11)) ... 279 ms
fpprec:1000000$
b3: 1.0b0/3$
round(b3) ... 32035 ms
round(rationalize(b3)) ... 9173 ms
... and for "floor" and "ceiling", the existing method can be faster:
floor(b3) ... 3 ms
floor(rationalize(b3)) ... 3288 ms;
ceiling(b3) ... 16379 ms
ceiling(rationalize(b3)) ... 3318 ms
so this may require some additional analysis.