Advertisement
ipsBruno

(Javascript) toFixed Equivalent

Apr 24th, 2012
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //      Função similar a toFixed. O parametro P indica quantas casas decimais você quer dado o valor i
  3. //      f(15.488389678834183438, 2) = 15.48
  4. //
  5.  
  6. function getFixed(i, p) {      
  7.         return p = Math.pow(10, p), Math.floor(i * p) / p
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement