Module Nativeint


module Nativeint: sig  end
プロセッサ native 整数です。

このモジュールでは符号付き 32 ビット整数 (32 ビットプラットフォームの場合) または 64 ビット整数 (64 ビットプラットフォームの場合) の nativeint 型を処理できます。この整数型は C コンパイラでの整数値 long と同じ幅の整数を持ちます。nativeint に関する算術演算はアーキテクチャのワードサイズに依存して 232 または 264 を法とする演算になります。

パフォーマンスについて: nativeint 型の値は int 型の値に比べて多くのメモリを必要とし、また int32 の算術処理は一般に int より遅くなります。nativeintint 型に足りないビット分の精度が必要なときだけ使用してください。


val zero : nativeint
native 整数の 0 。
val one : nativeint
native 整数の 1 。
val minus_one : nativeint
native 整数の -1 。
val neg : nativeint -> nativeint
単項否定。
val add : nativeint -> nativeint -> nativeint
加算。
val sub : nativeint -> nativeint -> nativeint
減算。
val mul : nativeint -> nativeint -> nativeint
乗算。
val div : nativeint -> nativeint -> nativeint
整数除算。第二引数が 0 である場合は例外 Division_by_zero を発生します。Pervasives.(/) の仕様のように、実数商は 0 方向に丸められます。
val rem : nativeint -> nativeint -> nativeint
整数剰余。y が 0 でない場合、Nativeint.rem x y の結果は Nativeint.zero <= Nativeint.rem x y < Nativeint.abs y かつ x = Nativeint.add (Nativeint.mul (Nativeint.div x y) y) (Nativeint.rem x y) という特性を持ちます。y = 0 である場合は Nativeint.rem x y は例外 Division_by_zero を発生します。
val succ : nativeint -> nativeint
1 加算。Nativeint.succ xNativeint.add x Nativeint.one です。
val pred : nativeint -> nativeint
1 減算。Nativeint.pred xNativeint.sub x Nativeint.one です。
val abs : nativeint -> nativeint
引数の絶対値を返します。
val size : int
native 整数のビット幅です。32 ビットプラットフォームでは 32 、64 ビットプラットフォームでは 64 です。
val max_int : nativeint
native 整数が表現できる最大の値です。32 ビットプラットフォームでは 231 - 1 、64 ビットプラットフォームでは 263 - 1 です。
val min_int : nativeint
native 整数が表現できる最小の値です。32 ビットプラットフォームでは -231 、64 ビットプラットフォームでは -263 です。
val logand : nativeint -> nativeint -> nativeint
ビット論理積。
val logor : nativeint -> nativeint -> nativeint
ビット論理和。
val logxor : nativeint -> nativeint -> nativeint
ビット排他的論理和。
val lognot : nativeint -> nativeint
ビット論理否定。
val shift_left : nativeint -> int -> nativeint
Nativeint.shift_left x yx を左に y ビットシフトします。 y < 0 または y >= bitsize のとき結果は規定されていません (bitsize は 32 ビットプラットフォームでは 32 、64 ビットプラットフォームでは 64 です) 。
val shift_right : nativeint -> int -> nativeint
Nativeint.shift_right x yx を右に y ビットシフトします。 これは算術シフトです。新しく空いた上位ビットには x の符号ビットが複製され挿入されます。 y < 0 または y >= bitsize のとき結果は規定されていません。
val shift_right_logical : nativeint -> int -> nativeint
Nativeint.shift_right_logical x yx を右に y ビットシフトします。 これは論理シフトです。新しく空いた上位ビットには x の符号ではなく常に 0 が入ります。 y < 0 または y >= 32 のとき結果は規定されていません。
val of_int : int -> nativeint
与えられた整数 (int 型) を native 整数 (nativeint 型) に変換します。
val to_int : nativeint -> int
native 整数 (nativeint 型) を整数 (int 型) に変換します。変換によって上位ビットを失います。
val of_float : float -> nativeint
浮動小数点小数を native 整数に変換します。小数部分は切り捨てます (0 方向に丸めます) 。切り捨て後、その数が [Nativeint.min_int, Nativeint.max_int] の範囲にない場合、変換結果は未定義です。

val to_float : nativeint -> float
native 整数を浮動小数点小数に変換します。
val of_int32 : int32 -> nativeint
32 ビット整数 (int32 型) を native 整数に変換します。
val to_int32 : nativeint -> int32
native 整数を 32 ビット整数 (int32 型) に変換します。64 ビットプラットフォームでは 64 ビット native 整数は 232 を法とした数になります。つまり上位 32 ビットを失います。32 ビットプラットフォームでは、変換による情報損失はありません。
val of_string : string -> nativeint
文字列を native 整数に変換します。 文字列は (デフォルトで) 10 進として解釈されます。文字列が 0x0o0b で始まっている場合はそれぞれ 16 進、8 進、2 進として解釈されます。 文字列が整数を表す文字列として不正であった場合は、例外 Failure "int_of_string" が発生します。
val to_string : nativeint -> string
引数を符号付き 10 進文字列表記したものを返します。
val format : string -> nativeint -> string
Nativeint.format fmt n は native 整数 n を、fmt 指定されたフォーマットで文字列表示して返します。 fmt%d%i%u%x%X%o のどれかになります。この関数は推奨されていません。代わりに Printf.sprintf%nx フォーマットを使用してください。

type t = nativeint
native 整数型の別名です。

val compare : t -> t -> int
native 整数の比較関数です。Pervasives.compare の仕様と同じです。型 t とこの関数 compare を使ってモジュール String を functor Set.MakeMap.Make の引数として渡すことができます。