Question: Came across this question previously on an interview. The requirements are to write a function that

1. Generates a number between 0..1
2. Never returns the same number
3. Can scale (called every few milliseconds and continuously for years)
4. Can use only 1mb of heap memory
5. Does not need to return as a decimal, can render directly to stdout

My idea was hacky at best which involved manipulating a string of the "0.1" then "0.11" then "0.12" etc. Since the requirements did not mention it had to be uniformly distributed, it does not need to be random. Another idea is generate a timestamp of the form yyyyMMddhhmmssSSS (where SSS is msec) then convert that to a string and prefix it with "0." . This way the values will always be unique.

It's a pretty open ended question and I'm curious how other people would tackle it.

Answer: 
Pseudo code that can do what you except *guarantee* no repeats.

1. Take your 1 MB allocation.
2. Randomly set every byte.
3. Echo to stdout as "`0.<bytes as integer string>`" (will be very long)
4. Go to #2

Your "Never returns the same number" is not guaranteed but it is extremely unlikely (1 in 2^8192) assuming a good implementation of Random.
If you are programming in C, the `nextafter()` family of functions are Posix-compatible functions useful for producing the next double after or before any given value. This will give you about 2^64 different values to output, if you output both positive and negative values. 

If you are required to print out the values, use the %a or %A format for exact representation. From the printf(3) man page: "For 'a' conversion, the double argument is converted to hexadecimal notation (using the letters abcdef) in the style [-]0xh.hhhhp±d..." "The default precision suffices for an exact representation of the value if an exact representation in base 2 exists..."

If you want to generate random numbers rather than sequentially ascending ones, perhaps do a google search for 64-bit KISS RNG. Implementations in Java, [C](http://www.cygwin.com/ml/gsl-discuss/2011-q1/msg00001.html), Ada, [Fortran](http://fortranwiki.org/fortran/show/kiss64), et al are available on the web. The period of 64-bit KISS RNG itself is ~ 2^250, but there are not that many 64-bit double-precision numbers, so some numbers will re-appear within 2^64 outputs, but with different neighbor values. On some systems, long doubles have 128-bit values; on others, only 80 or 96. Using long doubles, you could accordingly increase the number of different values output by combining two randoms into each output.

It may be that the point of this question in an interview is to figure out if you can recognize a silly spec when you see it.