fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. private static void Main() {
  6. Console.WriteLine(GetRandomDouble(double.MinValue, double.MaxValue));
  7. Console.WriteLine(GetRandomDouble(double.MinValue, 100.0));
  8. Console.WriteLine(GetRandomDouble(-100, double.MaxValue));
  9. Console.ReadLine();
  10. }
  11.  
  12. private static Random rng = new Random();
  13.  
  14. private static double GetRandomDouble(double min, double max)
  15. {
  16. // Get the base value, scale first and then shift.
  17. return rng.NextDouble()*(max - min) + min;
  18. }
  19. }
Success #stdin #stdout 0.04s 23968KB
stdin
Standard input is empty
stdout
1.71998160643309E+308
-1.68004762245102E+308
1.74595383409414E+308