Git Product home page Git Product logo

number-converter's Introduction

number-converter

The most powerful, accurate and robust number conversion tool developed in C# for .NET Framework 4.5 and higher.

Advantages over other converters

  • Handles both positive and negative numbers.
  • Handles a high range of numbers ranging from -1 to 1 Octillion; That is (+/-) 1,000,000,000,000,000,000,000,000,000.
  • Handles numbers with decimal places. e.g; 1,234.567 = One thousand, two hundred and thirty four point five six seven
  • Accurately uses commas & the and conjunction when converting large numbers to output a very grammatically correct sentence. e.g; 12,654,768,123 = Twelve billion, Six hundred and fifty four million, seven hundred and sixty eight million, one hundred and twenty three.
  • Fast and efficient conversions with speeds of less than 1 microsecronds.

Usage

using System;

namespace NumberConverter.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            NumberConverter numberConverter = new NumberConverter();

            string numberInWords = numberConverter.ConvertToWords("12,345.89");

            // Or (The method has been overloaded to handle both strings and numerical values)

            numberInWords = numberConverter.ConvertToWords(12345.89);

            Console.WriteLine(numberInWords);
            Console.ReadKey();
        }
    }
}

Output: Twelve thousand, three hundred and forty five point eight nine

Tips

Numbers greater than 999,999,999,999,999 - Nine hundred and ninety nine trillion, nine hundred and ninety nine billion, nine hundred and ninety nine million, nine hundred and ninety nine thousand, nine hundred and ninety nine should be passed as a string for accurate coversion.

i.e;

numberInWords = numberConverter.ConvertToWords("1,000,000,000,000,001"); //Will be One quadrillion and one. but
numberInWords = numberConverter.ConvertToWords(1000000000000001); //Will be Over one quadrillion.

Authors

  • Dennis Kay - C# Enthusiast - GitHub

number-converter's People

Contributors

denniskay101 avatar dkamau avatar

Stargazers

 avatar  avatar

number-converter's Issues

Convert 90 cents does not work

Hi,

Great work on this helper class. Just found out that passing 0.90 with money format returns "nine cents" instead of "ninty cents"

Cheers,
Victor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.