Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

Creating a unique identifier from 3 ints

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaTurk - 24 Jul 2007 18:24 GMT
Hi,

I was just curious how you would go about creating a unique identifier
with 3 ints.
Ben Voigt [C++ MVP] - 24 Jul 2007 18:42 GMT
> Hi,
>
> I was just curious how you would go about creating a unique identifier
> with 3 ints.

What is the range of the three inputs?  32-bit signed?

What is the data type needed for the output?  String?  Numeric?  Size
constraints?
iwdu15 - 24 Jul 2007 18:44 GMT
why not just use the Guid object?
Signature

-iwdu15

Nicholas Paldino [.NET/C# MVP] - 24 Jul 2007 18:45 GMT
DaTurk,

   I would treat the three integers as components of a larger, 96 bit
integer.  Because there isn't an algorithm for generating higly-unique
96-bit integers (unlike GUIDs, which are 128 bits), I would suggest starting
at 0, and then incrementing by 1 every time you need a new value (across the
96 bits, which you will have to code yourself).

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi,
>
> I was just curious how you would go about creating a unique identifier
> with 3 ints.
Nicholas Paldino [.NET/C# MVP] - 24 Jul 2007 18:57 GMT
For clarification, by 96-bit integer, I mean 96-bit unsigned integer.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> DaTurk,
>
[quoted text clipped - 8 lines]
>> I was just curious how you would go about creating a unique identifier
>> with 3 ints.
Ben Voigt [C++ MVP] - 24 Jul 2007 19:00 GMT
> DaTurk,
>
[quoted text clipped - 3 lines]
> starting at 0, and then incrementing by 1 every time you need a new value
> (across the 96 bits, which you will have to code yourself).

Too bad C# doesn't support the obfusc... I mean succinct syntax for handling
carry when incrementing a compound integer:

++num1 || ++num2 || ++num3; // num3 is most significant
Chris Dunaway - 24 Jul 2007 21:27 GMT
> Hi,
>
> I was just curious how you would go about creating a unique identifier
> with 3 ints.

Your question seems a little vague.  What are the 3 ints?  Just *any*
3 ints?  Perhaps a little more about what you are trying to accomplish
will suggest some viable alternatives.

Chris
ModelBuilder - 25 Jul 2007 04:06 GMT
The reason this seems vague is that you don't state whether you need to get
back to the three ints from the unique identifier.  If this is the case,
there are several options.  If it is not a requirement, then just return an
incrimented static counter.

> Hi,
>
> I was just curious how you would go about creating a unique identifier
> with 3 ints.
DaTurk - 30 Jul 2007 17:18 GMT
On Jul 24, 10:06 pm, ModelBuilder
<ModelBuil...@discussions.microsoft.com> wrote:
> The reason this seems vague is that you don't state whether you need to get
> back to the three ints from the unique identifier.  If this is the case,
[quoted text clipped - 7 lines]
>
> - Show quoted text -

My apologies.  I have three signed integers.  32 bit, c# integers.
They are part of a structure that I'm going to be storing, but it
takes looking at all three of them together to make sure that the
structures are not duplicated.  SO I was thinking I could just "or"
them together, or something of the like to create one unique
identifer.

I was thinking you could make all three strings, then append them, end
to end, and then convert them back to an int.  But, it could get
bigger then a 64 bit long, which is as big as I want to go.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.