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 6026605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:28:12+00:00 2026-05-23T04:28:12+00:00

how to Generate a unique sequence ID to be stored in unsigned long ?

  • 0

how to Generate a unique sequence ID to be stored in unsigned long ?
Getting seconds elapsed after 1970 would have been good idea but requirement is within a second the id might be updated , so second wont be unique !

  • 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-05-23T04:28:13+00:00Added an answer on May 23, 2026 at 4:28 am

    If your requirements are to pick something pseudo random, fast, reliably unique, and not used for requirement for crytographic security purposes, I offer up the following

    On Windows X86:

    __rdtsc() – is about as good of a sequential number as it gets. XOR the upper 32-bits of the return value with the lower 32-bits. As the lower 32-bits will cycle every couple of seconds

    #include <Windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <intrin.h>
    #include <stdint.h>
    
    uint32_t GetPseudoRandomNumber()
    {
        uint64_t t = _time64(NULL);
        uint64_t cpu = __rdtsc();
        uint32_t result;
        cpu = cpu ^ t;
        result = (cpu >> 32) ^ (cpu & 0xffffffff);
        return result;
    }
    
    uint32_t GetPseudoRandomNumber2()
    {
        GUID guid = {};
        uint32_t* pValue = (uint32_t*)&guid;
        uint32_t result;
    
        CoCreateGuid(&guid);
    
        result = pValue[0] ^ pValue[1] ^ pValue[2] ^ pValue[3];
    
        return result;
    }
    

    Other sources of entropy include GetTickCount() (unique to the millisecond)

    On Linux:
    Just read 4 bytes from /dev/urandom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented an algorithm that will generate unique names for files that will
What are the good ways to generate unique roughly sequential Ids (32 bits &
i want to generate a sequence of unique random numbers in the range of
I want to generate unique random, N-valued key. This key can contain numbers and
I want to generate unique id's everytime i call methode generateCustumerId(). The generated id
How to generate unique id's in Javascript? I know using uuid in java, but
I am trying to generate unique values in c# with the help of DateTime
I want to generate unique numbers for each class in my header, primes in
Do you know how OpenUDID generate unique device ID? Is there any chance that
How can I generate some unique random numbers between 1 and 100 using JavaScript?

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.