title: Significant Figures in JavaScript
body: <p>I have a few scientists for clients and they have some problems with how toPrecision is rounding in JavaScript. They want everything rounded to a MAX of 3 sig figs which works most of the time but let me give a few examples of what they want:</p>
  
  <p>Lab value to rounded value</p>
  
  <p>123.5 to 124</p>
  
  <p>1234 to 1230</p>
  
  <p>12.0 to 12.0</p>
  
  <p>0.003 to 0.003</p>
  
  <p>So in other words round things with more than 3 sig figs down to 3. If something has 1 or 2 sig figs DONT append a zero (as that implies the lab was more accurate then they really were) but also in the case of 12.0 DONT remove the zero (as that implies the lab is less accurate then they really were)</p>