Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

doubles places past decimal....


  • Please log in to reply
1 reply to this topic

#1 oldezwe

oldezwe

    CC Lurker

  • Just Joined
  • Pip
  • 8 posts

Posted 25 February 2011 - 10:45 PM

import java.text.*;
import java.util.Random;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;

public final class RandomGaussian {
  
  public static final void main(String... aArgs){
	  Random randomGenerator = new Random();
	  List<Integer> level = new ArrayList<Integer>();
	  level.add(37);
      level.add(56);
      level.add(22);
      level.add(19);
      
      
      int position = 0;
      int listsize = level.size();
      while(position < listsize){
      double randDouble = randomGenerator.nextInt(level.get(position));
      log("Generated : " + randDouble);
      position = position + 1;
      

      }
      
      log("Done.");
  }
  
  private static void log(String aMessage){
    System.out.println(aMessage);
  }
}


How do I get the doubles I print out to go 10 places past the decimal?
  • 0

#2 CommittedC0der

CommittedC0der

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1065 posts
  • Programming Language:C#
  • Learning:C#, JavaScript, PL/SQL

Posted 26 February 2011 - 12:04 AM

Try this,
Decimal Format : Double « Data Type « Java Tutorial

~ Committed.
  • 1
There IS a war going on for your mind.
Nothing of eternal significance happens besides prayer.




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download