i have been reading the UUID RFC at http://www.ietf.org/rfc/rfc4122.txt and experimenting using the python `uuid`

module. for ease of explanation, here is the UUID diagram lifted from the spec.

```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_low |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_hi_and_version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|clk_seq_hi_res | clk_seq_low | node (0-1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| node (2-5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```

according to my reading of the spec, the smallest type-1 UUID should have time_low, time_mid, clk_seq_hi_res, clk_seq_low, and node set to all 0s, and time_hi_and_version should have bit 15 set to 1. the largest type-1 UUID should have time_low, time_mid, clk_seq_hi_res, clk_seq_low, and node set to all 1s, and time_hi_and_version set to all 1s except for bits 12, 13, and 14.

however, attempting to generate these in python fails:

```
>>> u = uuid.UUID("{00000000-0000-0000-0001-00000000}")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py", line 134, in __init__
raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string
>>> u = uuid.UUID("{ffffffff-ffff-ffff-fff1-ffffffff}")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py", line 134, in __init__
raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string
```

i assume i'm reading the spec incorrectly, but i'm at a loss.

The problem is not with your particular values, but that you don't have enough values.

You've only provided 14 bytes' worth of data instead of 16, and that's what it's complaining about.

`UUID`

isn't checking the requirements of a type-1 UUID at all. If it did, it wouldn't be able to work for other UUID types, which have different requirements.

Try this:

```
In [58]: uuid.UUID("{00000000-0000-0000-0000-000000000000}")
Out[58]: UUID('00000000-0000-0000-0000-000000000000')
In [59]: uuid.UUID('{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}')
Out[59]: UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')
```

Meanwhile, you've also apparently mixed up the version and variant, and got your endianness backward. So let's start over from scratch.

according to my reading of the spec, the smallest type-1 UUID… should have time_low, time_mid, clk_seq_hi_res, clk_seq_low, and node set to all 0s

`clk_seq_hi_res`

is an abbreviation for `clock_sequence_hi_and_reserved`

, defined in section 4.1.2 as "The high field of the clock sequence multiplexed with the variant". The variant is defined in 4.1.1, and you want "The variant specified in this document", which sets the two most significant bits to 1 and 0, respectively. Therefore, this field cannot be all 0s, or all 1s. Since this is the *most* significant bits, not the least, that means that the upper nibble of octet 8 has to be one of `(8, 9, a, b)`

, not that the lower nibble has to be one of `(1, 5, 9, d)`

.

, and time_hi_and_version should have bit 15 set to 1.

No, the version number is described in 4.1.3 as the most significant 4 bits of the timestamp, and version 1 is defined as 0-0-0-1. So, bit 15 should be set to 0, and so should 14 and 13, and bit 12 should be set to 1. This means the entire top nibble of octet 6 has to be 1, not the lower nibble of octet 7.

So:

```
00000000-0000-1000-8000-000000000000
ffffffff-ffff-1fff-bfff-ffffffffffff
```

Note that the dates represented by these timestamps are a little silly. The former is midnight 15 Oct 1582, and the latter is in the 53rd century.* So, any library that *did* validate version-1 UUIDs might reject them.

Also, a node of all 0s is a global unicast MAC address of all 0s, and I'm not sure that's a valid IEEE-802 address. A node of all 1s is fine, because you're explicitly allowed to use a random number if you set the multicast bit.

* As various BBC documentaries and associated textbooks explain, by the 49th century, humanity will have time travel, which will force us to change all of our timestamp technology.

Similar Questions

I have a table with uuid and system column. I need a query to return only uuid's having system=1 but not the uuids with system= 1 and 2

If I enter for example 5 4 3 2 1 it gives 1 and 2 which is correct but if I enter 1 2 3 4 5 it gives 1 and 5 which is false....how to fix this? This program finds the smallest and second smallest elem

What is the smallest exact representation of 1/(2^x) that can be represented in the C programming language?

I'm writing an integer-based quadtree structure which builds up from the node, and not down. To do this, I need to discover the next largest node which contains all my elements. If I have a preexistin

What is the largest known Neo4j cluster (in db size, graph stats, or # of machines)?

I wanted to get smallest date and largest date stored in database. For that i used following query: select min(sauda_date) as MinDate,max(sauda_date) as MaxDate from tradefile And I got Following res

What would be the most efficient way to take n smallest numbers from a sequence, [ [1 2 3] [9 2 1] [2 3 4] [5 6 7] ] I would like to take 2 smallest from the sequence based on the first item, [1 2 3]

i had to make a program that told you the largest and smallest number of 5 numbers and i keep getting smallest = 0 and largest = 0 on output. i havent added comments or anything like that yet, and ive

I've got syntax problem with awk and I don't know how to fix it: awk -F: -v lim=100 '{if ($1 >= lim)} NR == 1 {line = $0; min = $1} NR > 1 && $1 < min {line = $0; min = $1} END {prin

Given a set s of formula, I want to find a smallest subset s' of s that implies every formula in s. I call s the smallest independent set because for every pair a,b in s' , a does not imply b and vice

While Scala actors are described as light-weight, Akka actors even more so, there is obviously some overhead to using them. So my question is, what is the smallest unit of work that is worth paralleli

I have an ip array like below and I want to convert it to smallest cidr subnet list. Is there a library for that in Java? For example: 1.1.3.0 1.1.3.1 1.1.3.2 1.1.3.3 .. 1.1.3.254 1.1.3.255 1.2.3.0 1.

I need some help with Arrays I'm trying to create a simple program that would get the smallest number's difference from the largest number on an Array but it seems like the loop I'm doing does not do

Simple question - In c++, what's the neatest way of getting which of two numbers (u0 and u1) is the smallest positive number? (that's still efficient) Every way I try it involves big if statements or

I have array of 1's and 0's only. Now I want to find smallest contiguous subset/subarray which contains at least K 0's. Example Array is 1 1 0 1 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 and K(6)

I am looking for the right way for loading new UUIDs or accessing the _session object in a couchapp behind a vhost. I have written a couchapp and everything workes well with the normal but ugly urls.

first of all, I want to assure that I'm aware of the fact, that rehashing is a sensible topic. However I'd like to hear some of your opinions, what approach you would take here. I'm building a distrib

What is the largest data type in google appengine go datastore. I come across a limitation in string type which is only permits 500 characters. Thank you!

Here is what I have to find the kth smallest value in a binary search tree: struct treeNode { int data; struct treeNode *left, *right: }; int rank(stuct treeNode* ptr, int k) { if(node == NULL) return

Given a matrix of size mxn containing 0's and 1's only. I need to find the largest sub-matrix which has equal number of 1's and 0's in it. Brute force approach would be O(m^2*n^2) Can we do any better

As per subject: what are the characters that can be used in hash keys or, if it's shorter, which ones can't be used? Also, are there any problems in using long hash keys (like full path names)?

I'm little confused with this simple program.I have to find third largest no in array.I have done some code but getting only second largest no problem in third largest no so please suggest me what is

The title above sums up my question, to clarify things an example is: array[0] = 1 array[1] = 3 array[2] = 7 // largest array[3] = 5 so the result I would like is 2, since it contains the largest ele

Is there a recommended smallest button size under normal conditions? By recommended I mean prescribed by some document like: Apple HCI Guidelines Windows UX Guidelines or some ISO standard.. By

I have two files which both have one number per line and need to compare both files to find the largest and smallest numbers. eg:- file1 2 34 5 file2 44 5 66 4 need to get 66 as largest number and 2

I need the smallest/largest floating point number in an OpenCL kernel program which involves computing log probability. I had a look on OpenCL reference manual but I cannot locate such constants. In

Ideally I would want something like example.com/resources/äFg4вNгё5, minimum number of visible characters, never mind that they have to be percent encoded before transmitting them over HTTP. Can you t

I'm working on my first Pylons project using SQLalchemy and sqlite. I'd like to use UUIDs as the primary key for one of my tables. I found the question below and I used the code to add a custom UUID()

I'm trying to calculate the smallest difference between two angles. This is my current code (a slight variation of something I found online): float a1 = MathHelper.ToDegrees(Rot); float a2 = MathHelpe

Write a method named smallestLargest that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user. You may assume the user enters a valid number gr

What is the list of valid @SuppressWarnings warning names in Java? The bit that come between the () in @SuppressWarnings().

I have a hashmap of objects. Each object has two attributes (let say int length and int weight). I want to remove k elements with the smallest length. What is the efficient way of doing this?

Is for example size_t x = -1u; if (x == -1u) ... valid? If this is valid it would prevent a warning. of course on a 32 bit system x should be 0xffffffff and on a 64 bit system it should be 0xffffffff

My question in Perl: Write a Perl Script with a subroutine that accepts a list of values and returns the largest,smallest and average values to the calling program. #!/usr/bin/perl sub large_and_small

Give a data structure that stores comparable objects and supports add() and get(k) operations [get(k) returns the kth smallest element in the data structure (1 <= k <= n)]. get(k) must be O(1) a

I was working on a method trying to create a array that will contain the 3 largest numbers. But there is an error in my code and I couldn't understand what I did wrong. Thanks! public class Method3 {

How to get indices of K smallest or largest elements in eaach row of a matrix in R? e.g. I have matrix: 2 3 1 65 2 46 7 9 3 2 9 45 3 5 7 24 65 87 3 6 34 76 54 33 6 I'd like to get Indices matrix of s

Can I cleanly use a private UUID variant/version? I use random UUIDs which I essentially consider to be big integers. Now I have the case where I would like to generate a private UUID which is not b

I dont really understand much about arrays but i need to know how to find and print the largest and smallest values of an array. The array is predefined by a read command, the user will be prompted to

I user Devise in my rails application to authenticate user. I find two method, warden.authenticate? and user.valid_password?. who can tell me what's difference between those.

void foo(Type1 a, Type2 b = value2) May I know what are the restrictions of Type2 to be a parameter that accepts default value? I reckon value2 of type2 should be decidable at compile time. For examp

I'm using MVC 4 in Visual Studio. I want to know how to create a file with the Controller.File() method. I understand I need to pass a file type. What are the valid file types? I'm not seeing this in

I Often need UUIDs inserted into files that I'm editing in Notepad++. Does anyone have a macro or add in that does this. Or an autohotkey script?

In my log I have many things like this: cache: [GET /assets/widget.png] stale, valid, store What does it mean? Is it a cache miss or hit? What does it mean to be stale and also valid?

I need to find the smallest element in a matrix. I have a solution, but it is not perfect. type Matrix = [[Int]] matMin :: Matrix -> Int matMin [] = 99999999999 matMin (xs:xss) = minimum xs `min` m

I wrote what is possibly the smallest wrapper around node-mongodb-native wrapper. But, I feel that it needs improving. It's so small it fits here comfortably: function MongoWrapper() { this.db = null;

Im trying to find the smallest number that is also false in my dictionary. I'm also using the new Swift Language. How can I make this work? var firstRow = [1: false, 2: false, 3: false, 4: false, 5: f

I've wrote a simple C program that finds the largest of 4 numbers. I'm trying all the possible combination of 4 digits number which currently limits to 1234. Due to some repeated formatting error whil

Passbook for iOS uses a serial number that your servers can use to identify a specific pass. Does anyone know what characters are valid in the passbook serial number? I know that digits and letters ar

I have a small header file of my own which declares a couple of functions, one of which has a return type of DWORD. I'm reluctant to drag in windows.h just to get the official definition of this type