Results 1 to 2 of 2
  1. #1
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    The Netherlands
    Rep Power

    Default Formatting numbers?

    hey im having a small problem right here.

    im making this little program that calculates stuff, but whenever the number gets too big it turns it into a number like this: 1.0E7
    instead of: 10000000

    do you guys know how i'm going to fix this?

    this is my code:
    Java Code:
    if(e.getSource()==b1 && box.getSelectedItem()==fish[0]){
    				String xp1 = txt1.getText();
    				int xp2 = Integer.parseInt(xp1);
    				String xp3 = txt2.getText();
    				int xp4 = Integer.parseInt(xp3);
    				double xpleft = xp4 - xp2 ;
    				double fishleft = xpleft / 13300;
    				JOptionPane.showMessageDialog(null, "XP left: "+"\t"+xpleft+"\n"+"Fishes left: "+"\t"+fishleft+"\n"+"\n"+"NOTE: always round these numbers."+"\n"+"example: fish left: 1,87 = fish left: 2.", "Fishing Calculator", JOptionPane.INFORMATION_MESSAGE);

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Formatting numbers?

    Have you looked through the API documentation? Hint: the name of the class starts with an F and ends with 'ormatter'.

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Numbers formatting with printf
    By Kaizer in forum New To Java
    Replies: 7
    Last Post: 11-10-2011, 04:38 AM
  2. Replies: 11
    Last Post: 01-14-2011, 06:36 PM
  3. formatting numbers in output
    By andy3 in forum New To Java
    Replies: 3
    Last Post: 05-27-2010, 06:43 PM
  4. Formatting numbers or decimals (around comma)
    By Joris in forum Advanced Java
    Replies: 1
    Last Post: 04-22-2010, 05:46 PM
  5. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-14-2008, 11: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