Sun Studio 12:Fortran 库参考

1.4.4.1 用法:andorxornotrshiftlshift

对于内函数:

x = and( word1, word2 )

x = or( word1, word2 )

x = xor( word1, word2 )

x = not( word )

x = rshift( word, nbits )

x = lshift( word, nbits )

wordword1word2nbits 都是整型输入参数。这些函数是编译器内联扩展的内函数。返回值的数据类型是第一个参数的数据类型。

不测试 nbits 的值是否合理。

示例:andorxornot


demo% cat tandornot.f
        print 1, and(7,4), or(7,4), xor(7,4), not(4)
 1      format(4x ’and(7,4)’, 5x ’or(7,4)’, 4x ’xor(7,4)’,
     1         6x ’not(4)’/4o12.11)
        end
demo% f95 tandornot.f
demo% a.out
    and(7,4)     or(7,4)    xor(7,4)      not(4)
 00000000004 00000000007 00000000003 37777777773
demo%

示例:lshiftrshift


demo% cat tlrshift.f
       integer*4 lshift, rshift
       print 1, lshift(7,1), rshift(4,1)
 1     format(1x ’lshift(7,1)’, 1x ’rshift(4,1)’/2o12.11)
       end
demo% f95 tlrshift.f
demo% a.out
 lshift(7,1) rshift(4,1)
 00000000016 00000000002
demo%