Menu

#3190 round/floor/ceiling slow for hi-precision bfloats

None
open
5
2024-06-03
2016-07-20
No

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

Discussion

  • Stavros Macrakis

    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.

     
  • Robert Dodier

    Robert Dodier - 2024-06-03
    • labels: --> round, floor, ceiling, bigfloat
     

Log in to post a comment.