Arithmetic with a specified (low) number of digits

Sure, you can set the precision of BigFloat to whatever you want, including very low numbers of digits. However, note that BigFloat is a fixed number of binary digits because it uses binary floating point.

julia> setprecision(BigFloat, 5, base=10); # set to roughly 5 decimal digits

julia> precision(BigFloat) # get actual number of binary digits
17

julia> H = BigFloat[1.000 0.5000 0.3333 0.2500
           0.5000 0.3333 0.2500 0.2000
           0.3333 0.2500 0.2000 0.1666
           0.2500 0.2000 0.1666 0.1428]

julia> cholesky(H)
Cholesky{BigFloat, Matrix{BigFloat}}
U factor:
4×4 UpperTriangular{BigFloat, Matrix{BigFloat}}:
 1.0  0.5      0.333302   0.25
  ⋅   0.28862  0.288784   0.259857
  ⋅    ⋅       0.0742636  0.110837
  ⋅    ⋅        ⋅         0.0221052

(You would need an arbitrary-precision decimal floating-point package to specify a precise number of decimal digits.)

3 Likes