safe_log

Function safe_log 

Source
pub fn safe_log(x: f64) -> Result<f64, String>
Expand description

Computes the natural logarithm of x, handling edge cases safely.

§Arguments

  • x - The input number.

§Returns

  • Result<f64> - The natural logarithm of x, or an error message if x is invalid.

§Errors

Returns an error if x is less than or equal to 0.