Hallo ich weiss, wie man folgende zufallszahlen generiert:
double zufall = Math.random(); // Zufallszahl im Bereich 0.0.... bis 0.99....
System.out.println(zufall);
int zufall = (int) (Math.random()*6); // Zufallszahl von 0 bis 5
System.out.println(zufall);
int zufall = 1+ (int) (Math.random()*6); // Zufallszahl von 1 bis 6
System.out.println(zufall);
ich verstehe aber nicht wie ich zufallszahlen im bereich -1.0 und 1.0 erhalte.
Für Hilfe wäre ich dankbar!
Thx, lg
double zufall = Math.random(); // Zufallszahl im Bereich 0.0.... bis 0.99....
System.out.println(zufall);
int zufall = (int) (Math.random()*6); // Zufallszahl von 0 bis 5
System.out.println(zufall);
int zufall = 1+ (int) (Math.random()*6); // Zufallszahl von 1 bis 6
System.out.println(zufall);
ich verstehe aber nicht wie ich zufallszahlen im bereich -1.0 und 1.0 erhalte.
Für Hilfe wäre ich dankbar!
Thx, lg