【ツール】%(パーセント)、ppm、ppb、ppt変換

  • URLをコピーしました!

%

ppm

ppb

ppt

1 %1 ppm1 ppb1 ppt
%1 0.0001
(1 x 10-4)
0.0000001
(1 x 10-7)
0.0000000001
(1 x 10-10)
ppm10, 000
(1 x 104)
10.001
(1 x 10-3)
0.000001
(1 x 10-6)
ppb10,000,000
(1 x 107)
1,000
(1 x 103)
10.001
(1 x 10-3)
ppt10,000,000,000
(1 x 1010)
1,000,000
(1 x 106)
1,000
(1 x 103)
1
<input type="Input" id="value" value="1">
<select id="order">
    <option value="percent" selected="">%</option>
    <option value="ppm">ppm</option>
    <option value="ppb">ppb</option>
    <option value="ppt">ppt</option>
</select>
<button onclick="buttonclick()">変換</button>

<p><span id="percent"></span> %</p>
<p><span id="ppm"></span> ppm</p>
<p><span id="ppb"></span> ppb</p>
<p><span id="ppt"></span> ppt</p>

<script> 
    function buttonclick(){
        let val = document.getElementById("value").value;
        let order = document.getElementById("order").value;
        console.log(val)
        console.log(order)

        let percent = document.getElementById("percent");
        let ppm = document.getElementById("ppm");
        let ppb = document.getElementById("ppb");
        let ppt = document.getElementById("ppt");

        let original_val
        if (order == "percent"){
            original_val = val;
        }else if (order == "ppm"){
            original_val = val * 10**(-4);
        }else if (order == "ppb"){
            original_val = val * 10**(-7);
        }else if (order == "ppt"){
            original_val = val * 10**(-10);
        }

        console.log(original_val)

        percent.textContent = original_val.toLocaleString(undefined, { maximumFractionDigits: 10 })
        ppm.textContent = (original_val * 10**4).toLocaleString(undefined, { maximumFractionDigits: 9 })
        ppb.textContent = (original_val * 10**7).toLocaleString(undefined, { maximumFractionDigits: 9 })
        ppt.textContent = (original_val * 10**10).toLocaleString(undefined, { maximumFractionDigits: 9 })
    }
</script>
よかったらシェアしてね!
  • URLをコピーしました!

コメント

コメントする

目次