View source code
Display the source code in std/int128.d from which this
page was generated on github.
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
local clone.
std.int128.Int128.opCast
- multiple declarations
Function Int128.opCast
Support casting to a bool
bool opCast(T)() const;
Parameters
Name | Description |
---|---|
T | bool |
Returns
true if value is not zero
Function Int128.opCast
Support casting to an integral type
T opCast(T)() const
if (is(byte : T));
Parameters
Name | Description |
---|---|
T | integral type |
Returns
low bits of value reinterpreted as T
Example
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
Function Int128.opCast
Support casting to floating point type
T opCast(T)() const;
Parameters
Name | Description |
---|---|
T | floating point type |
Returns
value cast to floating point with environment-dependent rounding if the value is not exactly representable
Example
const Int128 a = Int128(-1L << 60);
writeln(cast(double)a); // -(2.0^^60)
writeln(cast(double)(a * a)); // 2.0^^120
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.