The Real object provides a representation and associated operations for real numbers. It offers methods to create Real instances from various types (String, Int, Double, Rational), and provides several utilities, implicit conversions, and typeclass instances for operations and comparisons.
Attributes
Members list
Type members
Classlikes
Represents a constant Real number corresponding to "Not a Number" (NaN).
Represents a constant Real number corresponding to "Not a Number" (NaN).
This object is a specialized instance of Real, serving as a marker for undefined or unrepresentable numerical values within the Real number context.
Inherits all behavior and operations defined by the Real class, but specific methods and operations involving NaN may yield NaN or other behavior consistent with the IEEE 754 standard for floating-point arithmetic.
Attributes
- Supertypes
-
class Realtrait Serializabletrait Producttrait Equalstrait Fieldtrait Ordered[Field]trait Comparable[Field]trait Approximatabletrait Numericaltrait NumberLikeclass Objecttrait Matchableclass AnyShow all
- Self type
-
NaN.type
Attributes
- Companion
- trait
- Supertypes
-
trait RealIsFractionaltrait RealIsNumerictrait RealIsOrderingtrait Fractional[Real]trait Numeric[Real]trait Ordering[Real]trait PartialOrdering[Real]trait Equiv[Real]trait Serializabletrait Comparator[Real]class Objecttrait Matchableclass AnyShow all
- Self type
-
RealIsFractional.type
Following are the definitions required by Fractional[Real]
Following are the definitions required by Fractional[Real]
Attributes
- Companion
- object
- Supertypes
-
trait RealIsNumerictrait RealIsOrderingtrait Fractional[Real]trait Numeric[Real]trait Ordering[Real]trait PartialOrdering[Real]trait Equiv[Real]trait Serializabletrait Comparator[Real]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object RealIsFractional
Following are the definitions required by Numeric[Real]
Following are the definitions required by Numeric[Real]
Attributes
- Supertypes
- Known subtypes
-
object RealIsFractionaltrait RealIsFractional
Attributes
- Companion
- trait
- Supertypes
-
trait RealIsOrderingtrait Ordering[Real]trait PartialOrdering[Real]trait Equiv[Real]trait Serializabletrait Comparator[Real]class Objecttrait Matchableclass AnyShow all
- Self type
-
RealIsOrdering.type
Following are the definitions required by Ordering[Real]
Following are the definitions required by Ordering[Real]
Attributes
- Companion
- object
- Supertypes
- Known subtypes
Implicit class to operate on Numbers introduced as integers.
Implicit class to operate on Numbers introduced as integers.
CONSIDER generalizing this to inputs of Values (or Rationals, Doubles).
Value parameters
- x
-
an Int to be treated as a Real.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Inherited and Abstract types
The names of the product elements.
The names of the product elements.
Attributes
- Inherited from:
- Mirror
The name of the type.
The name of the type.
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
Constructs a new Real from the given string representation of a number.
Constructs a new Real from the given string representation of a number.
Value parameters
- w
-
the string to be parsed and converted into a Real.
Attributes
- Returns
-
a new Real instance representing the parsed number.
Constructs a Real object from an integer value.
Constructs a Real object from an integer value.
Value parameters
- x
-
the integer value to be converted to a
Real.
Attributes
- Returns
-
a
Realinstance representing the supplied integer.
Converts a double value into a Real object.
Converts a double value into a Real object.
Value parameters
- d
-
the double value to be converted
Attributes
- Returns
-
a Real object representing the provided double value
Converts a given Rational number into a Real number.
Converts a given Rational number into a Real number.
Value parameters
- r
-
the Rational number to be converted.
Attributes
- Returns
-
the corresponding Real number representation of the input Rational.
Converts a NumberLike instance into a Real.
Converts a NumberLike instance into a Real.
The conversion operation determines the specific subtype of NumberLike and handles it accordingly. If the input is a Rational, it delegates the processing to apply(Rational). If the input is a Number, it delegates the processing to apply(Number). Throws a CoreException if the input NumberLike cannot be converted into a Real.
Value parameters
- n
-
the
NumberLikeinstance to be converted to aReal.
Attributes
- Returns
-
a
Realrepresenting the convertedNumberLikeinput. - Note
-
Throws CoreException if the input cannot be converted into a
Real.
Computes the arctangent of two Field values and returns the result as a Real.
Computes the arctangent of two Field values and returns the result as a Real.
NOTE that Expression defines a more precise version of atan.
This operation calculates the arctangent of the ratio x / y, using their numeric representations. If either x or y cannot be converted into a numeric representation, the result is NaN.
Value parameters
- x
-
the first
Fieldinput, representing the numerator in the arctangent calculation. - y
-
the second
Fieldinput, representing the denominator in the arctangent calculation.
Attributes
- Returns
-
a
Realvalue representing the arctangent of the arguments, orNaNif the inputs are not valid numbers.
Creates a Real instance from a given Field if it can be represented as a real number.
Creates a Real instance from a given Field if it can be represented as a real number.
If the input Field is already a Real, it is returned as-is. If the input is a BaseComplex instance and is identified as real (i.e., has no imaginary component), the corresponding Real value is extracted. If the input cannot be represented as a Real, an exception is thrown.
Value parameters
- x
-
the input Field to be converted to a Real.
Attributes
- Returns
-
a Real instance representing the input Field.
- Note
-
Throws CoreException if the input Field is not real or cannot be converted to a Real.
CONSIDER inlining this method or making it private.
CONSIDER inlining this method or making it private.
Value parameters
- x
-
the first number.
- y
-
the second number.
Attributes
- Returns
-
the order.