This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes get the resultant value upto 2 decimal places. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "get the resultant value upto 2 decimal places." Watch "get the resultant value upto 2 decimal places." New topic
Author

get the resultant value upto 2 decimal places.

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
Hi,

In my Javascript function, I have somethins like this:



This would return the size of the file in bytes. (20064 for eg)
I want to convert the size too MB and correct upto 2 decimal palces.

How can I do this?


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15362
    
    6
var result = num.toFixed(2);
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: get the resultant value upto 2 decimal places.
 
Similar Threads
Setting precision for a double value
Java (Precision Problem)
Decode the Mnemonic
SetPrecision?
Decimals not converting to correct fractions