3 ms·
Physics (and more generally numerical simulations) is the killer app for Julia Language. No other language makes it as easy to work with arbitrary precision mat
by kloch 3y ago
Physics (and more generally numerical simulations) is the killer app for Julia Language. No other language makes it as easy to work with arbitrary precision math. Whatever precision you need/want, just call setprecision(), Initialize variables/constants as BigInt/BitFloat, then do all your math just like you would in C.
Just remember to put the value in quotes when initializing:
BigFloat("1.0") NOT BigFloat(1.0). Without quotes it's silently initialized as double precision (!)
- leephillips 3y agoI don’t see that: julia> BigFloat(1.0) |> typeof BigFloat
- eigenspace 3y agoThe problem isn't the type, it's the bits. If you convert from Float64, you'll get garbage bits once you go past the bits determined by float64: julia> BigFloat(1.1) 1.100000000000000088817841970012523233890533447265625 I'd recommend using the big string macro though isntead of converting explictly from a string: julia> big"1.1" 1.100000000000000000000000000000000000000000000000000000000000000000000000000003
- leephillips 3y agoOh, I see. Thank you. (And, in Julia’s defense, this is all spelled out in the documentation, immediately accessible from the REPL. I just never read it carefully enough.)
- kloch 3y ago> And, in Julia’s defense, this is all spelled out in the documentation, immediately accessible from the REPL. I just never read it carefully enough. My concern is most physicists won't read that either and may not even notice the loss of precision until it's too late (after a paper has been published).