SafeInt.opCast

Convert this value to floating-point. This always succeeds, although some loss of precision may occur if M.sizeof <= N.sizeof.

  1. M opCast()
    struct SafeInt(N, IntFlagPolicy _policy, Flag!"bitOps" bitOps = Yes.bitOps)
    const pure @safe nothrow @nogc
    M
    opCast
    (
    M
    )
    ()
    if (
    isFloatingPoint!M
    )
    if (
    isIntegral!N &&
    )
  2. M opCast()
  3. M opCast()

Examples

import checkedint.throws : SafeInt; // use IntFlagPolicy.throws

SafeInt!int n = 92;
auto f = cast(double)n;
static assert(is(typeof(f) == double));
assert(f == 92.0);

Meta