u64_less Function

public pure function u64_less(a, b) result(r)

.true. when a < b with both operands read as unsigned 64-bit values.

Fortran’s < compares the two’s-complement patterns as signed, so it reports -huge(0_int64) - 1_int64 (that is, 263 unsigned) as less than zero. Flipping the sign bit of both operands maps the unsigned order onto the signed order exactly, which is why this is a comparison of ieor(a, SIGN_BIT) against ieor(b, SIGN_BIT) and not a sequence of sign tests.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: a
integer(kind=int64), intent(in) :: b

Return Value logical


Called by

proc~~u64_less~~CalledByGraph proc~u64_less u64_less proc~pcg32_uniform_below pcg32_uniform_below proc~pcg32_uniform_below->proc~u64_less proc~splitmix64_uniform_below splitmix64_uniform_below proc~splitmix64_uniform_below->proc~u64_less proc~pcg32_next_bernoulli_ppm pcg32_next_bernoulli_ppm proc~pcg32_next_bernoulli_ppm->proc~pcg32_uniform_below proc~pcg32_next_range pcg32_next_range proc~pcg32_next_range->proc~pcg32_uniform_below proc~splitmix64_next_bernoulli_ppm splitmix64_next_bernoulli_ppm proc~splitmix64_next_bernoulli_ppm->proc~splitmix64_uniform_below proc~splitmix64_next_range splitmix64_next_range proc~splitmix64_next_range->proc~splitmix64_uniform_below interface~next_bernoulli_ppm next_bernoulli_ppm interface~next_bernoulli_ppm->proc~pcg32_next_bernoulli_ppm interface~next_bernoulli_ppm->proc~splitmix64_next_bernoulli_ppm interface~next_range next_range interface~next_range->proc~pcg32_next_range interface~next_range->proc~splitmix64_next_range

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private, parameter :: SIGN_BIT = ishft(1_int64, 63)

Source Code

   pure function u64_less(a, b) result(r)
      !! `.true.` when `a < b` with both operands read as unsigned 64-bit
      !! values.
      !!
      !! Fortran's `<` compares the two's-complement patterns as signed, so it
      !! reports `-huge(0_int64) - 1_int64` (that is, 2**63 unsigned) as *less than*
      !! zero. Flipping the sign bit of both operands maps the unsigned order
      !! onto the signed order exactly, which is why this is a comparison of
      !! `ieor(a, SIGN_BIT)` against `ieor(b, SIGN_BIT)` and not a sequence of
      !! sign tests.
      integer(int64), intent(in) :: a
      integer(int64), intent(in) :: b
      logical :: r

      integer(int64), parameter :: SIGN_BIT = ishft(1_int64, 63)

      r = ieor(a, SIGN_BIT) < ieor(b, SIGN_BIT)
   end function u64_less