=begin pod

=TITLE subset UInt

=SUBTITLE Unsigned Integer (arbitrary-precision)

The C<UInt> is defined as a subset of C<Int>:

=for code :skip-test
my subset UInt of Int where * >= 0;

Consequently, it cannot be instantiated or subclassed; however, that shouldn't affect most normal uses.

Some examples of its behavior and uses:

  my UInt $u = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff; # 64-bit unsigned value
  say $u.base(16); # OUTPUT: «FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF␤» (32 digits)
  ++$u;
  say $u.base(16); # OUTPUT: «100000000000000000000000000000000␤» (33 digits!)
  my Int $i = $u;
  say $i.base(16); # same as above
  say $u.WHAT;     # OUTPUT: «(Int)␤» - UInt is a subset, so the type is still Int.
  say $i.WHAT;     # OUTPUT: «(Int)␤»
  # Difference in assignment
  my UInt $a = 5;  # nothing wrong
  my UInt $b = -5; # Exception about failed type check
  my UInt $c = 0;
  --$c;            # Exception again
  CATCH { default { put .^name, ': ', .Str } };
  # OUTPUT: «X::TypeCheck::Assignment: Type check failed in assignment to $b; expected UInt but got Int (-5)␤»

  # Non-assignment operations are fine
  my UInt $d = 3;
  say $a - 3;      # OUTPUT: «-3␤»

=end pod
