The GeneralNumber object provides utility methods for performing various operations on numbers with particular emphasis on exact, fuzzy, and generalized numeric types. It aims to handle operations in a flexible way based on the types and factors associated with numbers.
Attributes
- Companion
- class
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
GeneralNumber.type
Members list
Value members
Concrete methods
Applies a given mathematical function along with its derivative to the specified number.
Applies a given mathematical function along with its derivative to the specified number.
Value parameters
- dfByDx
-
The derivative of the function
f, mapping a Double to a Double. - f
-
A function mapping a Double to a Double, representing the main operation to be applied.
- x
-
The input number on which the function
fand its derivative are to be applied.
Attributes
- Returns
-
A Try containing the resulting Number if the operation succeeds, or a failure if an error occurs.
Performs the multiplication operation between two numbers using a given factor.
Performs the multiplication operation between two numbers using a given factor.
Value parameters
- factor
-
an instance of Factor representing specific configuration or scaling rules for the operation
- p
-
the first number to be multiplied
- q
-
the second number to be multiplied
Attributes
- Returns
-
the result of multiplying the two numbers, represented as a Number
Checks if the given number is infinite.
Checks if the given number is infinite.
Value parameters
- x
-
the number to be checked for infinity.
Attributes
- Returns
-
true if the number is infinite, otherwise false.
Determines if the given number is equivalent to zero.
Determines if the given number is equivalent to zero.
Value parameters
- x
-
the number to check.
Attributes
- Returns
-
true if the number is zero, otherwise false.
Performs the addition operation between two numbers, combining them into a single resultant number as per the mathematical rules defined by their specific types and factors.
Performs the addition operation between two numbers, combining them into a single resultant number as per the mathematical rules defined by their specific types and factors.
Value parameters
- x
-
the first number to be added
- y
-
the second number to be added
Attributes
- Returns
-
the result of adding the two given numbers
Method to raise an (exact) Number to a power. NOTE: This method is invoked only by doPower (in ExactNumber).
Method to raise an (exact) Number to a power. NOTE: This method is invoked only by doPower (in ExactNumber).
TODO: move this into ExactNumber but CAREFULLY!
CONSIDER: surely that y.scale(PureNumber) might create a fuzzy number, right?
Value parameters
- x
-
the base Number (always exact).
- y
-
the power (may not be exact).
Attributes
- Returns
-
x raised to the power of y.
Computes the product of two Number instances recursively.
Computes the product of two Number instances recursively.
Value parameters
- x
-
the first operand, represented as a Number instance
- y
-
the second operand, represented as a Number instance
Attributes
- Returns
-
the result of multiplying x and y, represented as a Number instance
Concrete fields
A higher-order function that creates a new Number instance based on a provided prototype ProtoNumber and a Number instance.
A higher-order function that creates a new Number instance based on a provided prototype ProtoNumber and a Number instance.
Attributes
- Returns
-
A new
Numberinstance created by themakemethod of the providedNumber, using elements of the givenProtoNumber.