txt: ## real.md
  Real
  
  Combined from primary sources listed below.
  
  # [In DateTime](#___top "go to top of document")[§](#(DateTime)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/DateTime#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(DateTime:D: --> Instant:D)
  ```
  
  Converts the invocant to [`Instant`](/type/Instant). The same value can be obtained with the [`Instant`](/type/Instant) method.
  
  Available as of release 2023.02 of the Rakudo compiler.
  
  # [In Complex](#___top "go to top of document")[§](#(Complex)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/Complex#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(Complex:D: --> Num:D)
  multi method Real(Complex:U: --> Num:D)
  ```
  
  Coerces the invocant to [`Num`](/type/Num). If the imaginary part isn't [approximately](/routine/=~=) zero, coercion [fails](/routine/fail) with [`X::Numeric::Real`](/type/X/Numeric/Real).
  
  The `:D` variant returns the result of that coercion. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0e0`.
  
  # [In RatStr](#___top "go to top of document")[§](#(RatStr)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/RatStr#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(Real:D: --> Rat:D)
  multi method Real(Real:U: --> Rat:D)
  ```
  
  The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.
  
  # [In Date](#___top "go to top of document")[§](#(Date)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/Date#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(Date:D: --> Int:D)
  ```
  
  Converts the invocant to [`Int`](/type/Int). The same value can be obtained with the `daycount` method.
  
  Available as of release 2023.02 of the Rakudo compiler.
  
  # [In NumStr](#___top "go to top of document")[§](#(NumStr)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/NumStr#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(NumStr:D: --> Num:D)
  multi method Real(NumStr:U: --> Num:D)
  ```
  
  The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0e0`.
  
  # [In Cool](#___top "go to top of document")[§](#(Cool)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/Cool#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real()
  ```
  
  Coerces the invocant to a [`Numeric`](/type/Numeric) and calls its [`.Real`](/routine/Real) method. [Fails](/routine/fail) if the coercion to a [`Numeric`](/type/Numeric) cannot be done.
  
  ```raku
  say 1+0i.Real;            # OUTPUT: «1␤»
  say 2e1.Real;             # OUTPUT: «20␤»
  say 1.3.Real;             # OUTPUT: «1.3␤»
  say (-4/3).Real;          # OUTPUT: «-1.333333␤»
  say "foo".Real.^name;     # OUTPUT: «Failure␤»
  ```
  
  # [In ComplexStr](#___top "go to top of document")[§](#(ComplexStr)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/ComplexStr#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(ComplexStr:D: --> Num:D)
  multi method Real(ComplexStr:U: --> Num:D)
  ```
  
  Coerces the numeric portion of the invocant to [`Num`](/type/Num). If the imaginary part isn't [approximately](/language/operators#infix_≅) zero, coercion [fails](/routine/fail) with [`X::Numeric::Real`](/type/X/Numeric/Real).
  
  The `:D` variant returns the result of that coercion. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0e0`.
  
  # [In role Enumeration](#___top "go to top of document")[§](#(role_Enumeration)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/Enumeration#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(::?CLASS:D:)
  ```
  
  Takes a value of an enum and returns it after coercion to [`Real`](/type/Real):
  
  ```raku
  enum Numbers ( cool => '42', almost-pi => '3.14', sqrt-n-one => 'i' );
  say cool.Real;           # OUTPUT: «42␤»
  say almost-pi.Real;      # OUTPUT: «3.14␤»
  try say sqrt-n-one.Real;
  say $!.message if $!;    # OUTPUT: «Cannot convert 0+1i to Real: imaginary part not zero␤»
  ```
  
  Note that if the value cannot be coerced to [`Real`](/type/Real), an exception will be thrown.
  
  # [In IntStr](#___top "go to top of document")[§](#(IntStr)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/IntStr#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(IntStr:D: --> Int:D)
  multi method Real(IntStr:U: --> Int:D)
  ```
  
  The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0`.
  
  # [In role Real](#___top "go to top of document")[§](#(role_Real)_method_Real "direct link")
  
  See primary documentation
  [in context](/type/Real#method_Real)
  for **method Real**.
  
  ```raku
  multi method Real(Real:D: --> Real:D)
  multi method Real(Real:U: --> Real:D)
  ```
  
  The `:D` variant simply returns the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns `self.new`.
  