Re: random numbers in fortran
- From: robert.corbett@xxxxxxx
- Date: 27 Nov 2006 18:52:42 -0800
lane straatman wrote:
Since I want to simulate shuffling a deck of cards, I guess I'll ask
for 52 pseudorandoms at a pop, multiply by 52 and take the floor. I
believe this gives random ints between zero and fifty-one. Is a person
well advised to start his arrays at zero as with C?
On a machine that uses binary floatng-point, the result will
be between zero and 51 inclusive, assuming sensible
rounding (round toward positive infinity can produce 52).
On a machine that uses higher radix floating-point, such as
an IBM z-Series machine, the result can be in the range
[0, 52], even for sensible rounding. On such machines,
use truncating arithmetic, if possible, to avoid trouble.
Bob Corbett
.
- References:
- random numbers in fortran
- From: lane straatman
- Re: random numbers in fortran
- From: Thomas Koenig
- random numbers in fortran
- Prev by Date: Re: rounding a number
- Next by Date: Fortran Error Problem
- Previous by thread: Re: random numbers in fortran
- Next by thread: Re: random numbers in fortran
- Index(es):
Relevant Pages
|