Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:15:47+00:00 2026-06-16T19:15:47+00:00

Most modern computers exhibit non deterministic behavior, what makes impossible to tell how many

  • 0

Most modern computers exhibit non deterministic behavior, what makes impossible to tell how many clock cycles will occur between two consecutive calls to read the computer clock.

The following code is a pseudo random number generator for one byte using the computer clock.

unsigned long occurrences = 0;
unsigned long total = 0;

while (true) {
    if ((clock() & 0xFF) == 60) // testing ocurrences for a given number, 60 for instance
        occurrences++;
    total++;
    printf("%f\n", (float)occurrences / (float)total ); // this should be approximately 1/256 = 0.00390625
}

Excluding serious applications like encription for instance, it could be used in mobile platforms for games.

I wonder what could be the advantages and disadvantages of such implementation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:15:48+00:00Added an answer on June 16, 2026 at 7:15 pm

    You are missing the proper way to use rand() or, more specifically, srand().

    You need to call srand() exactly once during program run.
    Do not call srand() in a loop.
    Do not call srand() before each call to rand().
    The best way to ensure proper srand() management is to call it once inside your main() function and then forget about it: just use rand() afterwards.

    #include <stdlib.h> /* rand, srand */
    #include <time.h>   /* time */
    
    int main(void) {
        /* initialization */
        srand(time(NULL));
    
        /* input, possibly calling rand() */
    
        /* process, possibly calling rand() */
    
        /* output, possibly calling rand() */
    
        /* termination */
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In most modern systems, the system will automatically create extra files that are unnecessary.
In most modern IDEs there is a parameter that you can set to ensure
It appears that most modern languages and tools allow for extended regular expressions, and
I know modern browsers remove most space chars and '&nbsp'; characters insider a paragraph
Most somewhat modern programming languages have a standard library? It is my impression is
Most modern API's are built using JSON with request/response messaging over HTTP. Since ZeroMQ
In most modern OO languages chaining methods together is common, and IMHO elegant, practice.
It's standard in most modern editors that you can highlight a piece of code
I was just wondering what is the most modern/easiest/best practice was to create a
Where can I find the most modern tutorial that teaches tkinter together with ttk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.