英語版
このページの英語版を見る

std.int128

符号付き 128 ビット整数型を実装する。

作者 ウォルター・ブライト

struct Int128;
128ビット符号付き整数型。
Cent data;
コア.int128.セント
pure nothrow @nogc @safe this(long lo);
long 値からInt128 を構築する。 上位64ビットは符号拡張で形成される。
Parameters:
long lo 符号付き下位64ビット
pure nothrow @nogc @safe this(ulong lo);
ulong の値からInt128 を構築する。 上位64ビットはゼロに設定される。
Parameters:
ulong lo 符号なし下位64ビット
pure nothrow @nogc @safe this(long hi, long lo);
long の値からInt128 を構築する。
Parameters:
long hi 上位64ビット
long lo 下位64ビット
pure nothrow @nogc @safe this(Cent data);
Cent からInt128 を構築する。
Parameters:
Cent data セント・データ
const pure nothrow @nogc @safe size_t toHash();
Returns:
Int128のハッシュ値
const pure nothrow @nogc @safe bool opEquals(long lo);
等しいかどうかを比較する
Parameters:
long lo 比較する符号付き値
Returns:
Int128が値と等しい場合は真
const pure nothrow @nogc @safe bool opEquals(ulong lo);
等しいかどうかを比較する
Parameters:
ulong lo 比較する符号なし値
Returns:
Int128が値と等しい場合は真
const pure nothrow @nogc @safe bool opEquals(Int128 op2);
等しいか比較する
Parameters:
Int128 op2 比較する値
Returns:
Int128 と値が等しければ真
const Int128 opUnary(string op)()
if (op == "+");
単項演算子 + をサポートする
Parameters:
op "+"
Returns:
結果の"l値
const Int128 opUnary(string op)()
if (op == "-" || op == "~");
単項演算子 ~ をサポートする
Parameters:
op "-", "~"
Returns:
結果の"l値
Int128 opUnary(string op)()
if (op == "++" || op == "--");
単項演算子 ++ -- をサポートする。
Parameters:
op "++", "--"
Returns:
結果の"l値
const bool opCast(T : bool)();
boolへのキャストをサポートする
Parameters:
T ブール
Returns:
値がゼロでない場合にtrueを返す。
const T opCast(T : long)()
if (is(byte : T));
積分型へのキャストをサポートする。
Parameters:
T 積分型
Returns:
値の下位ビットはTとして再解釈される。
Examples:
const Int128 a = Int128(0xffff_ffff_ffff_ffffL, 0x0123_4567_89ab_cdefL);
writeln(cast(long)a); // 0x0123_4567_89ab_cdefL
writeln(cast(int)a); // 0x89ab_cdef
writeln(cast(byte)a); // cast(byte)0xef
const T opCast(T : real)();
浮動小数点型へのキャストをサポートする。
Parameters:
T 浮動小数点型
Returns:
環境依存の浮動小数点にキャストされた値。 値が正確に表現できない場合は丸める
Examples:
const Int128 a = Int128(-1L << 60);
writeln(cast(double)a); // -(2.0^^60)
writeln(cast(double)(a * a)); // 2.0^^120
const Int128 opBinary(string op)(Int128 op2)
if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^");

const Int128 opBinary(string op, Int)(const Int op2)
if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(Int : long) && __traits(isIntegral, Int));

const Int128 opBinary(string op, IntLike)(auto ref IntLike op2)
if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(IntLike : long) && !__traits(isIntegral, IntLike));

const Int128 opBinaryRight(string op, Int)(const Int op2)
if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(Int : long) && __traits(isIntegral, Int));

const Int128 opBinaryRight(string op, IntLike)(auto ref IntLike op2)
if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(IntLike : long) && !__traits(isIntegral, IntLike));

const Int128 opBinary(string op)(long op2)
if (op == "<<");

const Int128 opBinary(string op)(long op2)
if (op == ">>");

const Int128 opBinary(string op)(long op2)
if (op == ">>>");
二項演算子 + - * / % & | ^ << >> >> をサポートする。
Parameters:
op 算術二進演算子の1つ
Int128 op2 第2オペランド
Returns:
演算後の値
ref Int128 opOpAssign(string op)(Int128 op2)
if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^" || op == "<<" || op == ">>" || op == ">>>");

ref Int128 opOpAssign(string op, Int)(auto ref Int op2)
if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^" || op == "<<" || op == ">>" || op == ">>>") && is(Int : long));
算術代入演算子 += -= *= /= %= &= |= ^= <<= >>= >>=
Parameters:
op のいずれか。
Int128 op2 第2オペランド
Returns:
更新された左オペランドのl値
const pure nothrow @nogc @safe int opCmp(Int128 op2);

const pure nothrow @nogc @safe int opCmp(Int)(const Int op2)
if (is(Int : long) && __traits(isIntegral, Int));

const int opCmp(IntLike)(auto ref IntLike op2)
if (is(IntLike : long) && !__traits(isIntegral, IntLike));
算術比較演算子 < <= > >= をサポートする。
Parameters:
Int128 op2 右オペランド
Returns:
-より小さい場合は1、等しい場合は0、より大きい場合は1
const void toString(Writer, FormatSpec)(ref scope Writer sink, ref scope const FormatSpec fmt);
Int128 を、%d%x%X%s のいずれかでフォーマットする(%d と同じ)。
Parameters:
Writer sink 出力範囲 に書き込む。
FormatSpec fmt A std.format.FormatSpec数値の表示方法を制御する の表示方法を制御する。
Throws:
std.format.FormatException書式指定子が d'、'x'、'X'、's'のいずれかでない場合。
Examples:
toStringが直接呼び出されることはほとんどない。 std.format.format:
import std.format : format;

writeln(format("%s", Int128.max)); // "170141183460469231731687303715884105727"
writeln(format("%s", Int128.min)); // "-170141183460469231731687303715884105728"
writeln(format("%x", Int128.max)); // "7fffffffffffffffffffffffffffffff"
writeln(format("%X", Int128.max)); // "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
writeln(format("%032X", Int128(123L))); // "0000000000000000000000000000007B"
writeln(format("%+ 40d", Int128(123L))); // "                                    +123"
writeln(format("%+-40d", Int128(123L))); // "+123                                    "
Examples:
また、wchar またはdchar としてフォーマットすることもできる。
import std.conv : to;

writeln(to!wstring(Int128.max)); // "170141183460469231731687303715884105727"w
writeln(to!dstring(Int128.max)); // "170141183460469231731687303715884105727"d
enum Int128 min;
最小値
enum Int128 max;
最大値