Copyright © 2011-2015 Michael Truog
Version: 1.5.1 Sep 17 2015 13:50:24 ------------------------------------------------------------------------
Authors: Michael Truog (mjtruog [at] gmail (dot) com).
state() = #uuid_state{}
timestamp_type() = erlang | os | warp
uuid() = <<_:128>>
get_v1_datetime(Value::timestamp_type() | state() | uuid()) -> string()
get_v1_datetime(Value::timestamp_type() | state() | uuid(), MicroSecondsOffset::integer()) -> string()
get_v1_time() -> non_neg_integer()
get_v1_time(Uuid_state::timestamp_type() | state() | uuid()) -> non_neg_integer()
get_v1_time(Uuid_state) -> any()
get_v3(Data::binary()) -> uuid()
get_v3(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v3_compat(Data::binary()) -> uuid()
get_v3_compat(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v4() -> uuid()
get_v4(X1::strong | weak) -> uuid()
get_v4_urandom() -> uuid()
get_v4_urandom_bigint() -> uuid()
random:uniform/1 repeats every 2.78e13 (see B.A. Wichmann and I.D.Hill, in 'An efficient and portable pseudo-random number generator', Journal of Applied Statistics. AS183. 1982, or Byte March 1987) a single random:uniform/1 call can provide a maximum of 45 bits (currently this is not significantly faster because multiple function calls are necessary)
explain the 45 bits of randomness: random:uniform/0 code: B1 = (A1*171) rem 30269, B2 = (A2*172) rem 30307, B3 = (A3*170) rem 30323, put(random_seed, {B1,B2,B3}), R = A1/30269 + A2/30307 + A3/30323, R - trunc(R).
{B1, B2, B3} becomes the next seed value {A1, A2, A3}, so: R = (918999161 * A1 + 917846887 * A2 + 917362583 * A3) / 27817185604309 Whatever the values for A1, A2, and A3, (918999161 * A1 + 917846887 * A2 + 917362583 * A3) can not exceed 27817185604309 (30269 * 30307 * 30323) because of the previous modulus. So, random:uniform/1 is unable to uniformly sample numbers beyond a N of 27817185604309. The bits required to represent 27817185604309: 1> (math:log(27817185604309) / math:log(2)) + 1. 45.6610416965467get_v4_urandom_native() -> uuid()
get_v5(Data::binary()) -> uuid()
get_v5(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v5_compat(Data::binary()) -> uuid()
get_v5_compat(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
os or warp timestamp_type is used.
is_uuid(X1::any()) -> boolean()
is_v1(Value::any()) -> boolean()
is_v3(Value::any()) -> boolean()
is_v4(Value::any()) -> boolean()
is_v5(Value::any()) -> boolean()
mac_address() -> [non_neg_integer()]
new(Pid::pid()) -> state()
new(Pid::pid(), Options::timestamp_type() | [{timestamp_type, timestamp_type()} | {mac_address, [non_neg_integer()]}]) -> state()
erlang and os, respectively).
If you want erlang's adjustment of time without enforcement of increasing
time values, use the warp timestamp_type value with Erlang >= 18.0.
string_to_uuid(X1::string() | binary()) -> uuid()
test() -> ok
uuid_to_list(X1::uuid()) -> iolist()
uuid_to_string(Value::uuid()) -> string()
uuid_to_string(Value::uuid(), Option::standard | nodash | list_standard | list_nodash | binary_standard | binary_nodash) -> string() | binary()
Generated by EDoc, Sep 17 2015, 13:50:25.