Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Form t=a*x+c in 64 bits, get top and bottom 32 bits of t.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
George Marsaglia  
View profile  
 More options Jun 14 2007, 11:04 am
Newsgroups: alt.comp.lang.fortran
From: "George Marsaglia" <g...@stat.fsu.edu>
Date: Thu, 14 Jun 2007 11:04:47 -0400
Local: Thurs, Jun 14 2007 11:04 am
Subject: Form t=a*x+c in 64 bits, get top and bottom 32 bits of t.
Assembler instructions for most CPUs
permit forming the 64-bit product of
two 32-bit integers, then access to
the top and bottom parts.

Such operations provide the essentials
for a class of random number generators,
called
     multiply-with-carry (MWC) RNGs,
in which, given a 32-bit multiplier 'a',
and a current 32-bit pair x,c, one gets
a new pair by forming t=a*x+c  in 64 bits,
then the new c is the top 32 bits of t,
and the new x is the bottom 32 bits of t.

This is easy to do in C---for example,
this C code  produces 1000 integers from
a certain MWC RNG with period>2^60 and
excellent performance in tests of randomness:

unsigned long x=1234567,c=0;
unsigned long long t; int i;
for(i=0;i<1000;i++)
{t=695696193*x+c; c=t>>32; x=t; printf("%U",x); }

If Fortran allowed unsigned integers, that same
set of 1000 integers might be produced by a code
segment such as this:

   unsigned integer*4 x=1234567,c=0
   unsigned integer*8 t
   do 2 i=1,1000
   t=695696193*x+c
   c=ishft(t,-32)
   x=t
2  print*,x

Are there now any Fortran compilers
for which that code, or modifications,
could be implemented, permitting
formation of a*x+c in 64 bits,
then easy access to the top-32
and bottom-32 parts?

I switched from Fortran to C a number of
years ago, partly because the Fortran compiler
I used, Microsoft Fortran, would not run
on Windows XP, but also because Fortran
provided no easy way to get a 64-bit
version of a*x+c and extract the top and
bottom parts.

Are there any current Fortrans that do?

George Marsaglia


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »