help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UUIDGEN in lisp


From: Jesper Harder
Subject: Re: UUIDGEN in lisp
Date: Mon, 16 Feb 2004 18:10:04 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Brad Collins <brad@studiojungle.net> writes:

> I've looked this up in the elisp manual but don't really understand
> what is going on.  I noticed in the original script that the third
> field always would begin with the number four.

Yes,  it should be 4.  A random UUID is 128 bits, but only 122 bits
are random.  It's generated according to this algorithm[1]:

,----
|   The version 4 UUID is meant for generating UUIDs from truly-random or
|   pseudo-random numbers.
| 
|   The algorithm is as follows:
| 
|   .  Set the 2 most significant bits (bits numbered 6 and 7) of the
|      clock_seq_hi_and_reserved to 0 and 1, respectively.
| 
|   .  Set the 4 most significant bits (bits numbered 12 to 15 inclusive)
|      of the time_hi_and_version field to the 4-bit version number
|      corresponding to the UUID version being created, as shown in the
|      table above.  [0 1 0 0]
| 
|   .  Set all the other bits to randomly (or pseudo-randomly) chosen
|      values.
`----

The six non-random bits identify which kind of UUID it is, time-based,
random-based etc.

> What does `logior' and `logand' actually do in the script

They set the non-random bits.

> and what does the string #B01000000 mean?

It is read syntax for writing numbers in base 2. `#B01000000' is the
same as the number 64.

[1] 
http://hegel.ittc.ukans.edu/topics/internet/internet-drafts/draft-l/draft-leach-uuids-guids-01.txt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]