Real

com.phasmidsoftware.number.core.numerical.Real
See theReal companion class
object Real

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

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Real.type

Members list

Type members

Classlikes

object NaN extends Real

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 Real
trait Serializable
trait Product
trait Equals
trait Field
trait Ordered[Field]
trait Comparable[Field]
trait Numerical
trait NumberLike
class Object
trait Matchable
class Any
Show all
Self type
NaN.type

Attributes

Companion
trait
Supertypes
trait Fractional[Real]
trait Numeric[Real]
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Serializable
trait Comparator[Real]
class Object
trait Matchable
class Any
Show all
Self type
trait RealIsFractional extends Fractional[Real], RealIsNumeric

Following are the definitions required by Fractional[Real]

Following are the definitions required by Fractional[Real]

Attributes

Companion
object
Supertypes
trait Fractional[Real]
trait Numeric[Real]
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Serializable
trait Comparator[Real]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait RealIsNumeric extends Numeric[Real], RealIsOrdering

Following are the definitions required by Numeric[Real]

Following are the definitions required by Numeric[Real]

Attributes

Supertypes
trait Numeric[Real]
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Serializable
trait Comparator[Real]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
trait
Supertypes
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Serializable
trait Comparator[Real]
class Object
trait Matchable
class Any
Show all
Self type
trait RealIsOrdering extends Ordering[Real]

Following are the definitions required by Ordering[Real]

Following are the definitions required by Ordering[Real]

Attributes

Companion
object
Supertypes
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Serializable
trait Comparator[Real]
class Object
trait Matchable
class Any
Show all
Known subtypes
implicit class RealOps(x: Int)

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 Object
trait Matchable
class Any

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(w: String): Real

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.

def apply(x: Int): Real

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 Real instance representing the supplied integer.

def apply(d: Double): Real

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

def apply(r: Rational): Real

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.

def apply(n: NumberLike): Real

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 NumberLike instance to be converted to a Real.

Attributes

Returns

a Real representing the converted NumberLike input.

Note

Throws CoreException if the input cannot be converted into a Real.

def atan(x: Field, y: Field): 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 Field input, representing the numerator in the arctangent calculation.

y

the second Field input, representing the denominator in the arctangent calculation.

Attributes

Returns

a Real value representing the arctangent of the arguments, or NaN if 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.

def doCompare(x: Real, y: Real): Int

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.

def log(x: Field, y: Field): Real
def parse(w: String): Try[Real]

Method to parse a String and yield a Try[Number].

Method to parse a String and yield a Try[Number].

NOTE: this method indirectly invokes apply(Rational, Factor, Option of Fuzz[Double] )

Value parameters

w

the String to be parsed.

Attributes

Returns

a Number.

Implicits

Implicits

final implicit def RealOps(x: Int): RealOps

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