rnd

  1. LucaMs

    Android Code Snippet [B4X] RndPositiveLong - Generates a random POSITIVE Long

    Cross‑platform random 62‑bit generator (non‑negative values from 0 to 2^62−1), 'Generates a random non-negative Long number. Public Sub RndPositiveLong As Long ' Generates two random Ints up to 2^31−1 and combines them. Dim High As Long = Rnd(0, 2147483647) ' 31 bits Dim Low As...
  2. Mark Read

    B4J Question A stupid question to end the year.... How to generate a small number, positive or negative randomly.

    Yesterday whilst working on a project I needed to generate randomly a -1 or a 1. I tried for some time to get it working and thought how stupid can I be. Finally I came up with this: Dim RandomValue As Int=Rnd(1, 3)*-1 This was then to be used in the following line: If (center<>s) And...
  3. LucaMs

    B4A Class [B4X] Class - clsRndItems

    A simple class for randomly picking items from a group without repetitions (but also with repetitions, if desired). It works on all platforms (B4A, B4J, B4I), of course. Main methods: Initialize(..., NumOfItems As Int) Creates, by default, a list of numeric items, from 1 to NumOfItems you...
  4. Dragobyte

    Android Question Random function fails! Solved

    Hello everybody! Recently the classic routines that I used for many applications to shuffle numbers is failing, repeating numbers with no sense. I made a little app to point this. In this app, ALWAYS there is error when I click the fith time the button, and always are the same numbers repeated...
Top