floordiv Function

private pure function floordiv(a, b) result(f)

Return Python float floor division a // b for a, b > 0.

Follows CPython float_floor_div, so axis_offset picks exactly matplotlib's decades.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: a

Dividend.

real(kind=real64), intent(in) :: b

Divisor.

Return Value real(kind=real64)


Source Code

   pure function floordiv(a, b) result(f)
      !! Return Python float floor division `a // b` for `a, b > 0`.
      !!
      !! Follows CPython `float_floor_div`, so `axis_offset` picks exactly matplotlib's decades.
      ! Arguments
      real(real64), intent(in) :: a
         !! Dividend.
      real(real64), intent(in) :: b
         !! Divisor.
      real(real64) :: f, d
      d = (a - c_fmod(a, b))/b
      f = aint(d)
      if (d - f > 0.5d0) f = f + 1.d0
   end function floordiv