Android examples for java.util:Random Double
get random double value
//package com.java2s; import java.math.BigDecimal; import java.util.Random; public class Main { /**//w w w .jav a 2 s . c o m * get random double value * * @return */ public static double getRandomDou(double min, double max, int digitsNumber) { Random r = new Random(); double randomLimit = max - min; double dou = r.nextDouble() * randomLimit + min; BigDecimal bg = new BigDecimal(dou); dou = bg.setScale(digitsNumber, BigDecimal.ROUND_DOWN) .doubleValue(); return dou; } }