Exemplo n.º 1
0
        private static string GetWord(string number, WordNotation notation)
        {
            StrategyContext strategy = new StrategyContext();

            if (notation == WordNotation.Us)
            {
                strategy.SetNewStrategy(new UsCurrencyStrategy());
            }
            return(strategy.GetWord(number));
        }
Exemplo n.º 2
0
    public static string NotationMethod(BigDouble x, string y)
    {
        if (x <= 1000)
        {
            return(x.ToString(y));
        }
        if (x == NaN)
        {
            return("NaN Error Contact Dev");
        }
        switch (NotationSettings)
        {
        case 0:
        {
            var exponent = Floor(Log10(Abs(x)));
            var mantissa = x / Pow(10, exponent);

            var eexponent = Floor(Log10(exponent));
            var mexponent = exponent / Pow(10, eexponent);
            if (x < new BigDouble(1, 1000000))
            {
                return(mantissa.ToString("F2") + "e" + exponent);
            }
            else
            {
                return(mantissa.ToString("F2") + "e" + mexponent.ToString("F3") + "e" + eexponent);
            }
        }

        case 1:
        {
            var exponent = 3 * Floor(Log10(x) / 3);
            var mantissa = x / Pow(10, exponent);

            var eexponent = 3 * Floor(Log10(exponent) / 3);
            var mexponent = exponent / Pow(10, eexponent);

            if (x < new BigDouble(1, 1000000))
            {
                return(mantissa.ToString(y) + "e" + exponent);
            }
            else
            {
                return(mantissa.ToString("F0") + "e" + mexponent.ToString("F3") + "e" + eexponent);
            }
        }

        case 2:
        {
            return(WordNotation.Notate(x));
        }
        }
        return("");
    }
Exemplo n.º 3
0
 /// <summary>
 /// Used to Convert Real Number to Word
 /// </summary>
 /// <param name="num">Number</param>
 /// <param name="notation">Indian/Us</param>
 /// <returns>Number Representaion of Word</returns>
 public static string ToWord(decimal num, WordNotation notation = WordNotation.Indian)
 {
     return(GetWord(num.ToString(), notation));
 }