GLBasic forum

Other languages => GLBasic - de => Topic started by: Worebu on 2014-Sep-19

Title: Zufallszahl
Post by: Worebu on 2014-Sep-19
Hallo Leute,
kann mir einer sagen wieso mir hier manchmal eine auch eine Null generiert wird?

k = RND(53+1)

Ich sage doch extra +1, also kann theoretisch doch keine Null auftauchen, oder?

Dank im voraus für einen Tip.
Title: Re: Zufallszahl
Post by: erico on 2014-Sep-19
Keep the extra math off the brackets.
k=rnd(53)+1

The explanation is that the in brackets comes first, then it adds a 1.
In your case, (53+1) comes first, so you are actually pooling rnd(54).

Have you been skipping you math classes? :P
Title: Re: Zufallszahl
Post by: Worebu on 2014-Sep-19
Alles klar, kleiner Flüchtigkeitsfehler, solange hingeguckt und nichts gesehen. Danke. Und immer schön den Ball flach halten, Professor.