Sun Studio 12: Fortran ライブラリ・リファレンス

1.4.4.1 andor xornotrshift lshift の使用法

組み込み関数の場合は、次のように使います。

x = and( word1, word2 )

x = or( word1, word2 )

x = xor( word1, word2 )

x = not( word )

x = rshift( word, nbits )

x = lshift( word, nbits )

wordword1word2nbits は、整数型の入力引数です。これらは組み込み関数で、コンパイラによりインライン展開されます。戻されるデータの型は、第 1 引数のデータ型です。

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%