64-bit Random Number Generator

  • Follow


Hello;
Does anyone know any 64-bit number generators that work on 32-bit
machines by using long long or __int64 ?

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply Lexicon 6/25/2008 1:01:10 AM

Lexicon schreef:
> Hello;
> Does anyone know any 64-bit number generators that work on 32-bit
> machines by using long long or __int64 ?
> 
OT ?

sci.crypt.random-numbers

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply edwin 6/25/2008 4:56:47 PM


On Jun 25, 3:01 am, Lexicon <lex.do...@gmail.com> wrote:
> Does anyone know any 64-bit number generators that work on 32-bit
> machines by using long long or __int64 ?

I use boost::ecuyer1988.
http://www.boost.org/doc/libs/1_35_0/libs/random/random-generators.html#ecuyer1988

Does anyone know why it didn't become part of TR1?

- Marsh

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply Marsh 6/25/2008 4:59:08 PM

{ Top-posting is strongly discouraged in this group, please don't.
   So is quoting the clc++m banner, please please don't. -mod }

I haven't heard of such random generator, but you could easily create
one by wrapping any 32-bit RNG and roling it twice each time you need
to generate a 64-bit value.

[code]

  //rand32 could be any 32-bit random generator
unsigned long rand32();

unsigned long long rand64()
{
	return ( static_cast<unsigned long long>( rand32() ) << 32 ) |
rand32();
}
[/code]


Regards,
Martin

Lexicon wrote:
> Hello;
> Does anyone know any 64-bit number generators that work on 32-bit
> machines by using long long or __int64 ?
>
> --
>       [ See http://www.gotw.ca/resources/clcm.htm for info about ]
>       [ comp.lang.c++.moderated.    First time posters: Do this! ]

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply martinb 6/25/2008 5:02:13 PM

{ Top-posting is strongly discouraged in this group, please don't.
   So is quoting the clc++m banner, please please don't. -mod }

Sorry about the hasty post I just made. See
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html

On Jun 25, 11:01 am, Lexicon <lex.do...@gmail.com> wrote:
> Hello;
> Does anyone know any 64-bit number generators that work on 32-bit
> machines by using long long or __int64 ?
>
> --
>       [ Seehttp://www.gotw.ca/resources/clcm.htmfor info about ]
>       [ comp.lang.c++.moderated.    First time posters: Do this! ]


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply martinb 6/25/2008 5:02:35 PM

{ Top-posting is strongly discouraged in this group. Please don't. See other 
articles for examples of how to quote properly. TIA., -mod }


Perhaps something like this:

unsigned int seed = 0xA5A5A5A5;
boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
boost::uniform_int<long long> dist(std::numeric_limits<long
long>::min(),
                                    std::numeric_limits<long
long>::max());
boost::variate_generator<boost::mt19937&,boost::uniform_int<long long>
> rnd(rng,dist);
long long random_value = rnd();




Arash Partow
__________________________________________________
Be one who knows what they don't know,
Instead of being one who knows not what they don't know,
Thinking they know everything about all things.
http://www.partow.net




On Jun 25, 6:01 pm, Lexicon <lex.do...@gmail.com> wrote:
> Hello;
> Does anyone know any 64-bit number generators that work on 32-bit
> machines by using long long or __int64 ?
>

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply partow 6/29/2008 1:10:56 PM

If linear congruential scheme meets the requirements of your task, you
can look at http://nuclear.llnl.gov/CNP/rng/rngman/node4.html
However, it is not suitable for some tasks like cryptography, etc.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply vladimir 7/3/2008 8:02:49 AM

6 Replies
548 Views

(page loaded in 0.116 seconds)

Similiar Articles:













7/22/2012 4:06:52 PM


Reply: