This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Formatting a Number ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Formatting a Number ??" Watch "Formatting a Number ??" New topic
Author

Formatting a Number ??

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 340
Hi Eric,
I want to write a java function which will format a number upto four digit after decimal and if the number in fifth position after decimal is greater than and equal 5 then it should add 1 with fourth position number and if that number is smaller than 5 than it should trim the rest number after four digit after decimal.Can you please give me some idea how i can do that.
Thanks & Regards
Bikash
[ March 16, 2004: Message edited by: Bikash Paul ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
The following link shows how I did it for 2 decimal places, I am sure you can figure out how to make it work for 4.
http://www.coderanch.com/t/114331/HTML-JavaScript/simple-pl-help
If you need help just yell and I can guide you through it
Eric
[ March 16, 2004: Message edited by: Eric Pascarello ]
 
 
subject: Formatting a Number ??
 
Threads others viewed
how to read bit pattern?
Peculiar Problem with Rounding Number ??
Math.round() question
Number formatting function ??
Can anyone translate this ??
developer file tools