Results 1 to 2 of 2

Thread: Easy problem

  1. #1
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default Easy problem

    Lets an double type variable x is 232.1234567

    HOW CAN I PRINT ONLY Two value after the .means i want to print 232.12
    help me pls.

  2. #2
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    Read this:
    http://www.particle.kth.se/~lindsey/...terPrintf.html


    Here is an example:
    Java Code:
    public class DoubleExample {
    	static double numb = 12.34567;
    	
    	public static void main(String[] args) {
    		System.out.printf("%.2f", numb);
    	}
    }

Similar Threads

  1. Easy How do i fix it? it doesn't compile
    By HPcompaq256 in forum New To Java
    Replies: 18
    Last Post: 05-26-2010, 05:30 PM
  2. in need of help (easy)
    By fasck in forum New To Java
    Replies: 5
    Last Post: 12-30-2009, 11:45 PM
  3. how easy it is?
    By ron87 in forum New To Java
    Replies: 0
    Last Post: 04-01-2009, 07:36 PM
  4. Not so easy is it.
    By Roy Gardiner in forum Introductions
    Replies: 0
    Last Post: 10-24-2008, 05:59 PM
  5. What does this mean (Very Easy)
    By Zebra in forum New To Java
    Replies: 6
    Last Post: 05-01-2008, 02:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •