Computes sqrt(x) with protection against negative inputs.
Negative values are clamped to min_val before taking the root.
Examples
safe_sqrt(4)
#> [1] 2
suppressWarnings(safe_sqrt(-1))
#> [1] 0
Computes sqrt(x) with protection against negative inputs.
Negative values are clamped to min_val before taking the root.
safe_sqrt(4)
#> [1] 2
suppressWarnings(safe_sqrt(-1))
#> [1] 0