Post Reply 
Hp Algorithm to create random numbers
08-25-2024, 07:47 PM (This post was last modified: 08-25-2024 07:49 PM by DavidM.)
Post: #18
RE: Hp Algorithm to create random numbers
(08-25-2024 05:51 PM)Gil Wrote:  But could you detail the internal_seed with 2.567.
—> 257....001?

The computation of RAND is a straightforward chain of mathematical operations that's easy to describe. The conversion of a real number to a random seed (RDZ) isn't as easy to explain, mainly due to the variability of what happens during the denormalization process. Your best bet would be to step through the code with DBUG so you could watch the stack contents change with various inputs.

At a high level, RDZ/RDZU works as follows (using 2.567 as the example here):

1) The input is altered to conform to standard (non-zero positive real): 2.567E0

2) That value is separated into two intermediate pieces. mantissa (256700000000000) and exponent (0)

3) Denormalization occurs (the actual steps here vary with the input). For this example, the end result is:
Code:
2:      256700000000000       (mantissa)
1:                  001       (exponent)

4) exponent is then shifted left 1 digit:
Code:
2:      256700000000000       (mantissa)
1:                  010       (exponent)

5) exponent is incremented by 1:
Code:
2:      256700000000000       (mantissa)
1:                  011       (exponent)

6) Finally, the last three digits of mantissa are replaced by the full 3-digit form of exponent:
Code:
1:      256700000000011       (final seed value)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Hp Algorithm to create random numbers - DavidM - 08-25-2024 07:47 PM



User(s) browsing this thread: 12 Guest(s)