function k = i4_not ( i, j )

%*****************************************************************************80
%
%% I4_NOT calculates the NOT of an integer I with respect to J.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 January 2016
%
%  Author:
%
%   John Burkardt
%
%  Input:
%
%    integer I, the value whose NOT is needed.
%
%    integer J, the maximum value.
%
%  Output:
%
%    integer K, the NOT of I with respect to J.
%
  k = 0;
  l = 1;

  i = floor ( i );

  while ( j ~= 0 )
%
%  Check the current right-hand bits of I and J.
%
    i2 = floor ( i / 2 );

    if ( ( i == 2 * i2 ) )
      k = k + l;
    end

    i = i2;
    l = 2 * l;

    j = floor (  j / 2 );

  end

  return
end
