Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

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.

Creating Better Random Number with C++ and the MingGW Compiler

Featured Replies

Hi, in one of my gauges I need to create a random number between 1 and 100.This is my code so far. time1 = CLOCK_MINUTEvar.var_value.n ; int seed = time1; srand(seed); random= (rand()%100);It works ok, but the the generated "random" number isn't really that random. For example, if the Clock_Minute variable equals 44 minutes, the "random" generated number is always 82. Can anyone think of a way to bolster the "randomness" of this code?I'm using the MingGW compilier with the Easy Gauge Programmer's Ed.Thanks, Bryan

You might try using the last two digits of TICK18. Again, this is not completely random, but probably close enough.Doug

As far as I know you shouldn't "reseed" the random sequence every time, especially no with the same value. I assume you only need to use srand once at gauge loadup, or at least not with repitive numbers (e.g. srand((unsigned)time( NULL ) ); or ELAPSED_SECONDS instead of CLOCK_MINUTE). Arne Bartels

Create an account or sign in to comment

Account

Navigation

Search

Search

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.