Ejemplo n.º 1
0
        /// <summary>
        /// Format a numeric value using SI prefexes.
        ///
        /// eg: 13401 -> 13.4 k
        ///
        /// </summary>
        /// <param name="value">value to format</param>
        /// <param name="unit">unit string</param>
        /// <param name="exponent">Exponennt to the existing value. eg: if value was km rather than m this would be 3.</param>
        /// <param name="sigFigs">number of signifigant figures to display</param>
        /// <returns></returns>
        public static string ToStringSI(this float value, int sigFigs = 3, int exponent = 0, string unit = null)
        {
            EMRUtils.Log("Getting prefix for exponent of " + exponent);
            SIPrefix prefix = value.GetSIPrefix(exponent);

            EMRUtils.Log("Found prefix of " + prefix);
            return(prefix.FormatSI(value, sigFigs, exponent, unit));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Format a numeric value using SI prefexes.
        ///
        /// eg: 13401 -> 13.4 k
        ///
        /// </summary>
        /// <param name="value">value to format</param>
        /// <param name="unit">unit string</param>
        /// <param name="exponent">Exponennt to the existing value. eg: if value was km rather than m this would be 3.</param>
        /// <param name="sigFigs">number of signifigant figures to display</param>
        /// <returns></returns>
        public static string ToStringSI(this float value, int sigFigs = 3, int exponent = 0, string unit = null)
        {
            SIPrefix prefix = value.GetSIPrefix(exponent);

            return(prefix.FormatSI(value, sigFigs, exponent, unit));
        }