返回一个 32 位伪随机整数 harvest
,它在 int32
类型的奇数整数范围内均匀分布。(规范)
类型 | 意图 | 可选 | 属性 | 名称 | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(out) | :: | harvest |
subroutine odd_random_integer( harvest ) !! Version: experimental !! !! Returns a 32 bit pseudo random integer, `harvest`, distributed uniformly over !! the odd integers of the `int32` kind. !! ([Specification](../page/specs/stdlib_hash_procedures.html#odd_random_integer-returns-an-odd-integer)) integer(int32), intent(out) :: harvest real(dp) :: sample call random_number( sample ) harvest = int( floor( sample * 2_int64**32, int64 ) - 2_int64**31, & int32 ) harvest = ishft( harvest, 1 ) + 1_int32 end subroutine odd_random_integer