I have a piece of code getting the roots of an integer. I would like these roots to be rounded to something like 2 or 3 DP.
But Math.sqrt() (and eqivs for other roots) gives an automatically rounded square root.
I have done a bit of reaseach, and can’t find a simple way of getting this. I don’t really want to have to switch to another way, got to a library or anything else, Math.sqrt() is a nice easy way, just rounds it. Can I do this?
“rounded” here doesn’t mean “rounded to integer value”; from the API: “the result is the double value closest to the true mathematical square root of the argument value”.