/// <summary> /// Finds the base-10 logarithm of a number. /// </summary> /// <param name="number">Number greater than 0.</param> /// <returns name="log">Logarithm of the number.</returns> /// <search>logarithm</search> public static double Log10(double number) { return(CSMath.Log10(number)); }
// Return the new type char to use // opts.Precision will be set to the nubmer of digits to display after the decimal point private char AdjustForG(char type, double v) { if (type != 'G' && type != 'g') { return(type); } if (Double.IsNaN(v) || Double.IsInfinity(v)) { return(type); } double absV = SM.Abs(v); if ((v != 0.0) && // 0.0 should not be displayed as scientific notation absV < 1e-4 || // Values less than 0.0001 will need scientific notation absV >= SM.Pow(10, _opts.Precision)) // Values bigger than 1e<precision> will need scientific notation // One digit is displayed before the decimal point. Hence, we need one fewer than the precision after the decimal point { int fractionDigitsRequired = (_opts.Precision - 1); string expForm = absV.ToString("E" + fractionDigitsRequired); string mantissa = expForm.Substring(0, expForm.IndexOf('E')).TrimEnd(zero); // We do -2 to ignore the digit before the decimal point and the decimal point itself Debug.Assert(mantissa[1] == '.'); _opts.Precision = mantissa.Length - 2; type = (type == 'G') ? 'E' : 'e'; } else { // "0.000ddddd" is allowed when the precision is 5. The 3 leading zeros are not counted int numberDecimalDigits = _opts.Precision; if (absV < 1e-3) { numberDecimalDigits += 3; } else if (absV < 1e-2) { numberDecimalDigits += 2; } else if (absV < 1e-1) { numberDecimalDigits += 1; } string fixedPointForm = absV.ToString("F" + numberDecimalDigits, CultureInfo.InvariantCulture).TrimEnd(zero); string fraction = fixedPointForm.Substring(fixedPointForm.IndexOf('.') + 1); if (absV < 1.0) { _opts.Precision = fraction.Length; } else { int digitsBeforeDecimalPoint = 1 + (int)SM.Log10(absV); _opts.Precision = SM.Min(_opts.Precision - digitsBeforeDecimalPoint, fraction.Length); } type = 'f'; } return(type); }
public static double Log10(double value) { return(CSMath.Log10(value)); }
public static double Log10(double d) => Math.Log10(d);
public static double Log10(double d) { return(Math.Log10(d)); }
static double IFloatingPoint <double> .Log10(double x) => Math.Log10(x);
/// <summary> /// Represents the log base ten of e. /// </summary> /// <returns>System.Double.</returns> public static double Log10E() => NMath.Log10(NMath.E);