Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

$ZBITFIND (従来の関数)

ビット文字列関数 – FIND

Synopsis

$ZBITFIND(bitstring, truthval, position)

パラメータ

bitstring ビット文字列。
truthval バイナリ値 (0 あるいは 1)。
position オプションbitstring の中のビット開始位置を指定します。

概要

ここでは、従来の関数である $ZBITFIND について説明します。ここでは、従来のアプリケーションとの互換性について説明します。

$ZBITFIND は、bitstring の中で truthval と同じ値を持つ最初のビットの直後の位置を返します。position は、オプションで検索の開始位置を指定します。position が省略されている場合、1 の位置から検索を開始します。

truthval が見つからない場合、$ZBITFIND は 0 を返します。

$ZBITFIND は、一致するビットの直後の位置を返すという点で $FIND 関数と似ています。ループ形式を使用することもできます。

Findabit
  FOR p=1:0 {
      SET p=$ZBITFIND(bstring,1,p) 
      QUIT:´p 
      DO Foundone
   }
Foundone

パラメータ

truthval

バイナリ値 (0 あるいは 1)。

position

bitstring の中のビット開始位置を指定します。既定は 1 です。ビットは左から右にカウントされ、最初のビットは 1 となります。

以下の例で得られる結果は、truthval に一致するビットの直後の位置です。

bitstring[0,0,1,1,0] の場合 :

truthval=0 であれば、$ZBITFIND の結果は位置 2 です。

truthval=1 であれば、$ZBITFIND の結果は位置 4 です。

truthval=0 と position=2 であれば、$ZBITFIND の結果は位置 3 です。

truthval=0 と position=3 であれば、$ZBITFIND の結果は位置 6 です。

関連項目

FeedbackOpens in a new tab