Comment on page
Subtract A - B
Subtraction is an operation that represents removal of objects from a collection
The Subtract A - B block in the GraphLinq IDE is an essential mathematical component that calculates the difference between two numeric values. This block allows developers to perform subtraction operations on various numeric data types, enabling them to handle scenarios where finding the difference between two values is necessary.
The Subtract A - B block belongs to the Math blocks category in the GraphLinq IDE. Like other blocks in this category, it is a non-executive block, meaning it does not have yellow connectors and is implicitly called when other blocks require its output during graph execution.
The Subtract A - B block requires two input parameters:
- 1.A (Numeric Type): The A input represents the first numeric value for the subtraction operation.
- 2.B (Numeric Type): The B input denotes the second numeric value to be subtracted from the first value.
Both A and B can be any type of numeric data, such as decimal, integer, or long. The two data types do not need to match; for instance, you can subtract a decimal value from an integer value.
The Subtract A - B block outputs the result of the subtraction operation between A and B. The output will be of the same numeric type as the input values.
Let's explore a practical example demonstrating the usage of the Subtract A - B block in a graph:
- 1.The graph retrieves two numerical values, "TotalRevenue" and "OperatingCost," which represent a company's financial data.
- 2.The Subtract A - B block is invoked, with TotalRevenue as input A and OperatingCost as input B.
- 3.The block calculates the difference between TotalRevenue and OperatingCost, yielding the net income or profit generated by the company.
- 4.The output of the Subtract A - B block represents the net income, which can be further utilized for analysis, display, or other financial computations.
In this example, the Subtract A - B block enables the graph to perform a fundamental subtraction operation, allowing developers to compute key financial metrics, such as profit or loss, and make informed decisions based on the calculated results.
The Subtract A - B block is a critical mathematical tool in the GraphLinq IDE, providing the ability to calculate the difference between two numeric values. Its versatility allows for various applications, such as financial modeling, data analysis, and performance evaluations. By leveraging the Subtract A - B block, developers can handle subtraction operations efficiently within their graphs, ensuring accuracy and precision in the final output.
The Subtract A - B block in the GraphLinq IDE is a powerful tool for performing subtraction operations between two numeric values, A and B. This block takes two inputs, A and B, and calculates the result of subtracting B from A. The output of this operation is the difference between the two input values.
The "Subtract A - B" block is incredibly useful in scenarios where you need to calculate the difference or change between two numerical values. It is commonly employed in financial applications for calculating profits or losses, in data analysis for finding variations between data points, and in various other mathematical computations that involve subtraction.
Let's consider an example where we have two variables, A = 10 and B = 5. By connecting these variables to the "Subtract A - B" block, the result will be 5. This represents the difference between A and B.
Subtract A - Bblocks subtract one given number from another, and then output the result.
Subtract A - Bblocks have two input parameters called "A" and "B". These are, of course, the two numbers we want to calculate the difference of. Note that these input parameters can be supplied with any type of numeric data (decimal, integer, long), and the two data types do not need to match (ie: you can subtract a decimal value from an integer value).
As with all block types in the
Subtract A - Bblocks are non-executive blocks, which means that they have no yellow connectors, and thus they are never called explicitly by other blocks, and they themselves cannot call other blocks. Instead, they are called implicitly whenever their output is required as input by some other block that is executing. We can observe this happening in the example below.
This example is somewhat involved. The point of this graph is to print the 5-minute candle delta (change in price over 5 minutes) of the GLQ token, every 5 minutes. Since we are calculating the difference of two prices, we benefit from the use of a
Subtract A - Bblock.
The rest of the graph is driven by a
Timerblock, which fires every 5 minutes (300 seconds). Whenever it fires, it calls a
Get CoinGecko Coinblock, which retrieves the current price of GLQ. This price is then passed to our
Subtract A - Bblock, which substracts from it the price from 5 minutes before (stored in the variable "lastPrice"). The output of our
Subtract A - Bblock is thus the 5-minute price delta of GLQ. We pack this into a short message using a
Replace String In Stringblock and then print it into the graph's log using a
Set variableblock to assign the current price of GLQ to the variable "lastPrice", so that when the
Timerblock next fires in 5 minutes, that variable will contain the 5-minute-old price of GLQ.
Note that the yellow executive output on the
Get CoinGecko Coinblock is plugged directly into the
Get CoinGecko Coinblock. However, for the
Replace String In Stringblock to resolve, which in turn causes the
Subtract A - Bblock to resolve. This is an example of implicit calling, where a non-executive block is called only when its output is required by some other block's input.