Free html code | Decimal to fraction convertor HTML code

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 
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 . 

Here is a code for Decimal to fraction convertor HTML code    

<html lang="en">


    <meta charset="UTF-8"></meta>

    <meta content="width=device-width, initial-scale=1.0" name="viewport"></meta>

    <title>Decimal to Fraction Converter</title>


        body {

            font-family: Arial, sans-serif;

            text-align: center;

            margin: 50px;





    <h2>Decimal to Fraction Converter</h2>

    <label for="decimalInput">Enter Decimal:</label>

    <input id="decimalInput" placeholder="Enter decimal" step="any" type="number" />

    <button onclick="convertDecimalToFraction()">Convert</button>

    <p id="result"></p>


        function convertDecimalToFraction() {

            // Get the decimal input value

            var decimalInput = document.getElementById("decimalInput").value;

            // Convert decimal to fraction using a library or algorithm

            var fraction = decimalToFraction(decimalInput);

            // Display the result

            document.getElementById("result").innerHTML = "Fraction: " + fraction;


        // Function to convert decimal to fraction

        function decimalToFraction(decimal) {

            // Use a library or algorithm to convert decimal to fraction

            // Here, we are using a simple algorithm for demonstration purposes

            var tolerance = 1.0E-9;

            var h1 = 1;

            var h2 = 0;

            var k1 = 0;

            var k2 = 1;

            var b = decimal;

            do {

                var a = Math.floor(b);

                var aux = h1;

                h1 = a * h1 + h2;

                h2 = aux;

                aux = k1;

                k1 = a * k1 + k2;

                k2 = aux;

                b = 1 / (b - a);

            } while (Math.abs(decimal - h1 / k1) > decimal * tolerance);

            return h1 + "/" + k1;






Popular posts from this blog

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

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

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