-
…in reply to @rockerest
Alright, I'm no mathematician, but I think this is a bit too cute. Particularly:
& 15which reduces an 8 bit value to a MAXIMUM 4 bit value. I think this function works to create UUIDs that match a format, but possibly (??) with drastically reduced randomness. -
…in reply to @rockerest
Caveat: I really don't know. The RFC 4122 spec isn't something I feel like studying at the moment, and my bitmath is awful. This just has a feel about it...
-
…in reply to @rockerest
And by the way: golfing algorithms like this grinds my _fucking_ gears. There are FOUR math operations in a single expression with exactly zero parentheses. Nobody cares how many bytes your code is. No one. Are you generating UUIDs on an embedded device in JS? No. Stop it.
-
…in reply to @rockerest
(No one cares how many bytes your authored code is. Your executed code is a different story.)
-
…in reply to @rockerest
By the way, it's possible this washes in the end: A "better" algorithm would generate the same 8 bit random value 16 times (which I believe the spec demands). However, this algorithm generates the 8 bit value truncated to 4 bits (via & 15) THIRTY ONE times... So maybe a wash.
