メインコンテンツ

storedInteger

fi オブジェクトの格納整数値を取得

説明

y = storedInteger(a) は、fi オブジェクト a の格納整数値を返します。格納整数 y は、組み込みの整数データ型のいずれかとして返されます。

fi オブジェクトの実際値は次のように表すことができます。

real-world value=(slope×stored integer)+bias

バイアスがゼロで傾きが 2 のべき乗の場合、一般に 2 進小数点スケーリングと呼ばれ、多くの場合は次のように表されます。

real-world value=2fraction length×stored integer

すべて折りたたむ

この例では、storedInteger 関数を使用して 2 つの fi オブジェクトの格納整数値を調べる方法を示します。

既定の固定小数点データ型を使用して fi オブジェクト a を定義します。

a = fi([0.2 0.3 0.4 0.5]);
in_a = storedInteger(a)
in_a = 1×4 int16 row vector

    6554    9830   13107   16384

fi コンストラクターは既定では符号付き 16 ビット データ型を使用して fi オブジェクトを作成するため、int16 データ型で fi オブジェクト a の整数格納値が返されます。

numerictype オブジェクト nt で指定された固定小数点データ型を使用して fi オブジェクト a_nt を定義します。

nt = numerictype('WordLength',17);
a_nt = fi([0.2 0.3 0.4 0.5; 0.2 0.3 0.4 0.5],'numerictype',nt);
in_a_nt = storedInteger(a_nt)
in_a_nt = 2×4 int32 matrix

    6554    9830   13107   16384
    6554    9830   13107   16384

17 ビット以上の組み込みの整数データ型で最も小さいデータ型は int32 であるため、そのデータ型で fi オブジェクト a_nt の格納整数値が返されます。

入力引数

すべて折りたたむ

格納整数値を取得する固定小数点数値オブジェクト。スカラー、ベクトル、行列、または多次元配列の fi オブジェクトとして指定します。

データ型: fi
複素数のサポート: あり

出力引数

すべて折りたたむ

入力 fi オブジェクト a の格納整数値。組み込みの整数データ型のいずれかとして返されます。出力の次元は入力と同じになります。出力のデータ型は格納整数の符号属性と語長 (WL) に基づいて決まります。

入力の語長出力のデータ型
WL ≤ 8 ビットint8 または uint8
8 ビット < WL ≤ 16 ビットint16 または uint16
16 ビット < WL ≤ 32 ビットint32 または uint32
32 ビット < WL ≤ 64 ビットint64 または uint64

データ型: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

制限

  • storedInteger 関数では 64 ビットを超える整数はサポートされていません。出力のデータ型が 65 ビット以上の場合、storedInteger 関数でエラーが発生します。以下に例を示します。

    storedInteger(fi(1,0,65,0))
    
    Integers greater than 64 bits are not supported in 
    the 'storedInteger' function. For exact integer 
    representation for any word length, use BIN, OCT, 
    DEC, or HEX. To convert a stored integer value to 
    double for any word length, use storedIntegerToDouble.

ヒント

  • 任意の語長の正確な整数表現を取得するには、bindechexoct、または sdec を使用します。

  • 任意の語長の格納整数値を倍精度に変換するには、storedIntegerToDouble 関数を使用します。

代替機能

関数

int 関数と storedInteger 関数は、どちらも fi オブジェクトの格納整数値を返します。int 関数は、fi オブジェクトの格納整数の取得と設定の両方に使用できます。

a = fi(pi);
y = int(a)  %get
y =

  int16

   25736
a = fi(pi);
a.int = 3;  %set
y = a.int   %get
y =

  int16

   3
storedInteger 関数は、fi オブジェクトの格納整数値の取得にのみ使用できます。
a = fi(pi);
y = storedInteger(a) 
y =

  int16

   25736
storedInteger 関数は、fi オブジェクトの格納整数値の設定には使用できません。

拡張機能

すべて展開する

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2012a で導入

参考

| | | | |