Java by API/java.text/ChoiceFormat
ChoiceFormat: nextDouble(double d)
 
import java.text.ChoiceFormat;
public class Main {
  public static void main(String[] argv) throws Exception {
    double d = 1.2;
    double d2 = ChoiceFormat.nextDouble(d);
    System.out.println(d2);
  }
}
//1.2000000000000002
   
   
ChoiceFormat: previousDouble(double d)
 
import java.text.ChoiceFormat;
public class Main {
  public static void main(String[] argv) throws Exception {
    double d = 1.2;
    // Get the largest double less than d
    double d1 = ChoiceFormat.previousDouble(d);
    System.out.println(d1);
  }
}
//1.1999999999999997
   
   
new ChoiceFormat(double[] limits, String[] formats)
 
import java.text.ChoiceFormat;
public class Main {
  public static void main(String args[]) {
    double limits[] = { 0.0, 0.1, 0.3, 0.7 };
    String labels[] = { "very low", "low", "moderate", "high" };
    ChoiceFormat format = new ChoiceFormat(limits, labels);
    double r = Math.random();
    
    System.out.println(format.format(r) + " (" + r + ").");
  }
}
//high (0.755370803805559).