decimal to text converter html code - numbers to word converter

 welcome to new post , in this post you will find a code for Decimal to text converter or Numbers to word converter . You can add this code to your website and run your online calculator . 

This code is free and you no need to pay for code now.
We will try to give you a new code for every day . 
You can create your tool website and earn unlimited with google and google adsense. 
You can create your free website with the google product name as Blogger. 
You just open Blogger.com 
create your account and write or paste this code in the html view of your blogger. 

so the Code is given below you can copy and paste in your website . 






<html>
  <head>
    <title>Decimal to Text Converter</title>
    <script>
      function convertToText() {
        // Get the input value
        var decimal = document.getElementById("decimal").value;

        // Define arrays for text representation
        var units = [
          "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
          "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
          "eighteen", "nineteen"
        ];
        var tens = [
          "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
        ];
        var scales = ["", "thousand", "million", "billion", "trillion"];

        // Function to convert a three-digit number to text
        function convertThreeDigitNumber(num) {
          var result = "";

          // Convert hundreds place
          if (num >= 100) {
            result += units[Math.floor(num / 100)] + " hundred ";
            num %= 100;
          }

          // Convert tens and ones place
          if (num >= 20) {
            result += tens[Math.floor(num / 10)] + " ";
            num %= 10;
          }

          // Convert ones place for numbers below 20
          if (num > 0) {
            result += units[num] + " ";
          }

          return result.trim();
        }

        // Convert the decimal number to text
        var num = parseFloat(decimal);
        var resultText = "";

        if (num === 0) {
          resultText = "zero";
        } else {
          var sign = num < 0 ? "negative " : "";
          num = Math.abs(num);
          var scaleIndex = 0;

          while (num > 0) {
            var chunk = num % 1000;

            if (chunk !== 0) {
              var chunkText = convertThreeDigitNumber(chunk);
              resultText = chunkText + " " + scales[scaleIndex] + " " + resultText;
            }

            num = Math.floor(num / 1000);
            scaleIndex++;
          }

          resultText = sign + resultText.trim();
        }

        // Display the result
        document.getElementById("result").textContent = resultText;
      }
    </script>
  </head>
  <body>
    <h1>Decimal to Text Converter</h1>
    <label for="decimal">Enter a decimal number:</label>
    <input id="decimal" type="text" />
    <button onclick="convertToText()">Convert</button>
    <p id="result"></p>
  </body>
</html>


Decimal to Text Converter

Decimal to Text Converter

Comments

Popular posts from this blog

बस माल पैक करो और कंपनी को वापस कर दो और 60 हजार रुपए महीना कमाओ, bindi packing business

घर बैठे करे पैकिंग का काम कमाए लाखो रूपये महीना , पॉपकॉर्न कंपनी दे रही है मौका

3 ONLINE EARNING APP , NO CONDITION , NO INVESTMENT , ONLY EARNING , घर बैठे पैसा कमाने के लिए 3 सबसे बढ़िया APP .