Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich würde gern in Java 5.0 eine Zufallszahl zwischen 33 und 125 erzeugen.

double c = Math.ceil(Math.random()*125);

Mit diesem Befehl erzeuge ich leider alles zwischen 0 und 125, wie kann ich das ganze einschränken? So dass nie ein Wert kleiner 33 raus kommt?

Jemand ne Idee?

Gruß

:uli

Hi Leute,

ich würde gern in Java 5.0 eine Zufallszahl zwischen 33 und 125 erzeugen.

double c = Math.ceil(Math.random()*125);

Mit diesem Befehl erzeuge ich leider alles zwischen 0 und 125, wie kann ich das ganze einschränken? So dass nie ein Wert kleiner 33 raus kommt?

Jemand ne Idee?

Gruß

:uli

Ja, ich hatte da so ne Idee:

double c = Math.ceil(Math.random()*(125-33))+33;

double c = 100;

while(c < 33){

c = Math.ceil(Math.random()*125);

}

sollts auch tun :)

double c = 100;

while(c < 33){

c = Math.ceil(Math.random()*125);

}

sollts auch tun :)

Nur das du hier die dem Rechner gegebene Gleichverteilung der Zufallszahlen missbrauchst und vielleicht nicht zufällige (gleichverteilte) Zahlen, sondern zufällige (nichtgleichverteilte) Zahlen bekommst, je nach interner Programmroutine.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.