3 ms·
If you need higher precision you could always either simply bump up the accuracy a bit using e.g. https://github.com/JuliaMath/DoubleDouble.jl https://github.co
by kristofferc 8y ago
If you need higher precision you could always either simply bump up the accuracy a bit using e.g. https://github.com/JuliaMath/DoubleDouble.jl https://github.com/JuliaMath/DoubleDouble.jl or you can use the arbitrary precision numbers in Julia (https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/index.html#Arbitrary-Precision-Arithmetic-1 https://docs.julialang.org/en/v1/manual/integers-and-floatin...)
The performance will of course change accordingly.
- ColinWright 8y agoIs there an arbitrary precision square root routine? I've not found it ...
- kristofferc 8y agoThe concrete routine that is dispatched to is based on the type of the input number. So `sqrt(2.0)` will, in the end, call the assembly-instruction (depending on your specific CPU) `vsqrtss` since the input type is a 64-bit float, `sqrt(Float32(2.0))` will end up calling `vsqrtsd`, `sqrt(big"2.0")` will call the sqrt from the arbitrary precision library (MPFR) since we now have a "BigFloat" number etc. Directly from a Julia REPL session: julia> sqrt(2.0) 1.4142135623730951 julia> sqrt(Float32(2.0)) 1.4142135f0 julia> sqrt(big"2.0") 1.414213562373095048801688724209698078569671875376948073176679737990732478462102 julia> setprecision(512) # Bump the precision 512 julia> sqrt(big"2.0") 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993586
- ColinWright 8y agoYes, but I'm talking about getting exact BigInt ceil square roots of BigInt inputs. I've not found anything about whether that is supported natively or in a library.