Undo javascript calculation with | 0 to round the number

60 views Asked by At

I have following table and JavaScript that calculates my temperature to farenheid.

I want to toggle between celcius and Fahrenheit but obviesly if i reverse the calculation after I round the number the temperature is different.

I would like the original number back. I have About 200 different numbers all with the same class. I hope somone could help me. Thank you.

function change_to_gf()
  {

  var myClasses = document.getElementsByClassName("a_e");
  for (var i = 0; i < myClasses.length; i++)
    {
    myClasses[i].innerHTML = (((myClasses[i].innerHTML -32 ) / 1.8) | 0)
    }
 
  var myClasses = document.getElementsByClassName("a_mr");
  for (var i = 0; i < myClasses.length; i++)
    {
    myClasses[i].innerHTML = (((myClasses[i].innerHTML -32 ) / 1.8 | 0))
    }
  }
<table style="width:920px;" align="center" id="sort1" data-name="mytable" class="4sort1">
  <tr>
    <td style="width:60px;" class="a_e" id="exo_bist_e"/>48
    <td style="width:60px;" class="a_mr" id="exo_bist_mr"/>52
  </tr>
</table>

0

There are 0 answers