Report a bug
		
				If you spot a problem with this page, click here to create a Bugzilla issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	std.int128
Implements a signed 128 bit integer type.
Author Walter Bright
License: 
Source std/int128.d
- structInt128;
- 128 bit signed integer type.- Centdata;
- core.int128.Cent
- pure nothrow @nogc @safe this(longlo);
- Construct an Int128 from a long value. The upper 64 bits are formed by sign extension.Parameters:long losigned lower 64 bits 
- pure nothrow @nogc @safe this(ulonglo);
- Construct an Int128 from a ulong value. The upper 64 bits are set to zero.Parameters:ulong lounsigned lower 64 bits 
- pure nothrow @nogc @safe this(longhi, longlo);
- Construct an Int128 from a long value.Parameters:long hiupper 64 bits long lolower 64 bits 
- pure nothrow @nogc @safe this(Centdata);
- Construct an Int128 from a Cent.Parameters:Cent dataCent data 
- pure nothrow @nogc @safe size_ttoHash() const;
- Returns:hash value for Int128
- pure nothrow @nogc @safe boolopEquals(longlo) const;
- Compare for equalityParameters:long losigned value to compare with Returns:true if Int128 equals value
- pure nothrow @nogc @safe boolopEquals(ulonglo) const;
- Compare for equalityParameters:ulong lounsigned value to compare with Returns:true if Int128 equals value
- pure nothrow @nogc @safe boolopEquals(Int128op2) const;
- Compare for equalityParameters:Int128 op2value to compare with Returns:true if Int128 equals value
- Int128opUnary(string op)() const
 if (op == "+");
- Support unary arithmentic operator +Parameters:op "+" Returns:lvalue of result
- Int128opUnary(string op)() const
 if (op == "-" || op == "~");
- Support unary arithmentic operator - ~Parameters:op "-", "~" Returns:lvalue of result
- Int128opUnary(string op)()
 if (op == "++" || op == "--");
- Support unary arithmentic operator ++ --Parameters:op "++", "--" Returns:lvalue of result
- boolopCast(T : bool)() const;
- Support casting to a boolParameters:T bool Returns:true if value is not zero
- TopCast(T : long)() const
 if (is(byte : T));
- Support casting to an integral typeParameters:T integral type Returns:low bits of value reinterpreted as TExamples: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 
- TopCast(T : real)() const;
- Support casting to floating point typeParameters:T floating point type Returns:value cast to floating point with environment-dependent rounding if the value is not exactly representableExamples:const Int128 a = Int128(-1L << 60); writeln(cast(double)a); // -(2.0^^60) writeln(cast(double)(a * a)); // 2.0^^120 
- Int128opBinary(string op)(Int128op2) const
 if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^");
 Int128opBinary(string op, Int)(const Intop2) const
 if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(Int : long) && __traits(isIntegral, Int));
 Int128opBinary(string op, IntLike)(auto ref IntLikeop2) const
 if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(IntLike : long) && !__traits(isIntegral, IntLike));
 Int128opBinaryRight(string op, Int)(const Intop2) const
 if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(Int : long) && __traits(isIntegral, Int));
 Int128opBinaryRight(string op, IntLike)(auto ref IntLikeop2) const
 if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^") && is(IntLike : long) && !__traits(isIntegral, IntLike));
 Int128opBinary(string op)(longop2) const
 if (op == "<<");
 Int128opBinary(string op)(longop2) const
 if (op == ">>");
 Int128opBinary(string op)(longop2) const
 if (op == ">>>");
- Support binary arithmetic operators + - * / % & | ^ << >> >>>Parameters:op one of the arithmetic binary operators Int128 op2second operand Returns:value after the operation is applied
- ref Int128opOpAssign(string op)(Int128op2)
 if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^" || op == "<<" || op == ">>" || op == ">>>");
 ref Int128opOpAssign(string op, Int)(auto ref Intop2)
 if ((op == "+" || op == "-" || op == "*" || op == "/" || op == "%" || op == "&" || op == "|" || op == "^" || op == "<<" || op == ">>" || op == ">>>") && is(Int : long));
- arithmetic assignment operators += -= *= /= %= &= |= ^= <<= >>= >>>=Parameters:op one of +, -, etc. Int128 op2second operand Returns:lvalue of updated left operand
- pure nothrow @nogc @safe intopCmp(Int128op2) const;
 pure nothrow @nogc @safe intopCmp(Int)(const Intop2) const
 if (is(Int : long) && __traits(isIntegral, Int));
 intopCmp(IntLike)(auto ref IntLikeop2) const
 if (is(IntLike : long) && !__traits(isIntegral, IntLike));
- support arithmentic comparison operators < <= > >=Parameters:Int128 op2right hand operand Returns:-1 for less than, 0 for equals, 1 for greater than
- voidtoString(Writer, FormatSpec)(ref scope Writersink, ref scope const FormatSpecfmt) const;
- Formats Int128 with either %d, %x, %X, or %s (same as %d).Parameters:Writer sinkOutput range to write to. FormatSpec fmtA std.format.FormatSpec which controls how the number is displayed. Throws:std.format.FormatException if the format specifier is not one of 'd', 'x', 'X', 's'.See Also:Examples:toStringis rarely directly invoked; the usual way of using it is via 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:Also can format as wchar or dchar.import std.conv : to; writeln(to!wstring(Int128.max)); // "170141183460469231731687303715884105727"w writeln(to!dstring(Int128.max)); // "170141183460469231731687303715884105727"d 
- enum Int128min;
- minimum value
- enum Int128max;
- maximum value
 
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Fri Oct 10 22:10:08 2025