LogoLogo
Github
  • Overview
    • 📄Litepaper
  • GraphLinq Chain
    • Networks
      • Specs
        • Geth Client
        • Clique Consensus
      • GraphLinq Chain (Mainnet)
        • Wallet
          • Add GraphLinq Chain to Metamask
          • Add GraphLinq Chain To Ledger
        • RPC Public Nodes
        • Json-RPC API
        • Libraries
        • Execution Clients
        • Explorer
        • Status
    • GLQ
      • Allocation
      • Bridge
      • Rewards
  • 🎶Run a node
    • Installation
  • Dev tooling
    • Introduction
      • Vision
    • Graphs
      • What are Graphs and how do they work?
      • Creating a graph
      • File compression
      • Graph Cycle Costs
      • Node & Fees
    • Engine
      • Setting up the environment
      • Running an Engine locally
    • Dashboard Interface
      • Importing Graph/Template
      • Deploying a Graph
      • Managing Graph State
    • Blocks
      • Base Variable
        • Boolean
        • Decimal
        • Integer
        • KeyValue
        • Long
        • String
        • Get variable
        • Is Variable Exist
        • Set variable
        • Variable Portal
        • Secret String
      • Common
        • Entry Point
        • On Graph Start
        • Stop Graph
      • Time
        • Get Milliseconds Timestamp
        • Get Milliseconds Timestamp Offset
        • Get Timestamp
        • Get Timestamp Offset
        • Timer
        • Format Date
        • Millisecond Timestamp to Date
        • Timestamp to Date
        • Execution Time Interval
      • JSON
        • Last Node to JSON
        • Convert To JSON
        • Add JSON Property
        • Create JSON Object
        • JSON Deserialize To Array
        • JSON to JSON Object
        • Merge JSON
        • Serialize JSON Object
        • Serialize to JSON
      • Log
        • Print
      • WebSocket
        • WebSocket Client Close
        • WebSocket Client Connector
        • On WebSocket Client Disconnect
        • WebSock Receive Data Event
        • WebSocket Send Data
      • String
        • String Contains
        • Concat String
        • Replace String in String
      • Math
        • Subtract A - B
        • Add A + B
        • Ceiling
        • Divide A / B
        • Floor
        • Modulo A % B
        • Multiply A * B
        • Percentage Difference
        • Round
      • HTTP
        • Array To Body Values
        • Array To JSON Body
        • Put HTTP Request
        • Post HTTP Request
        • Get HTTP Request
        • Delete HTTP Request
      • Function
        • Function Block
        • Add Function Parameter
        • Set Function Result
        • Call Function
        • Get Function Result Parameter
        • Get Function Parameter
      • Transformers
        • String to Base64
      • Data
      • CSV
      • Base Condition
        • Decimal Branch
        • Integer Branch
        • String Branch
        • Boolean Branch
      • Range Condition
        • Decimal Range Branch
      • Array
        • Add Array Element
        • Clear Array
        • Create Array
        • Each Element In Array
        • Get Array Element At Index
        • Get Array Size
        • Keep Last X Elements In Array
      • Dictionary
      • Hosted API
    • Blocks (Messaging)
      • Twitter
      • Twitch
      • Telegram
      • SMTP
      • ShortenURL
      • PushOver
      • PushBullet
      • OpenAI
      • Discord
        • Add Emoji On Message
        • Send Discord Channel File
        • Add Role User
        • On Discord Channel Message
        • On Reaction Added Message
        • On Reaction Removed Message
        • Remove Role User
        • Reply Private Discord Message
        • Send Discord Channel Message
        • Discord Connector
        • On Discord Private Message
    • Blocks (Exchange)
      • Binance
      • Bitfinex
      • Bittrex
      • CoinEx
      • CoinGecko
        • Get CoinGecko Coin
      • Huobi
      • Kraken
      • KuCoin
      • LiveCoinWatch
      • MXC
    • Blocks (Blockchains)
      • Avalanche
        • Network Blocks
          • Avalanche Connector
          • Get Block Parameters
          • Get Transaction Parameters
          • On Avalanche Block
          • On Avalanche Transaction
        • Avascan
          • Get Avascan Supply
          • Get Avascan Global Stats
          • Get Avascan Staking Stats
          • Get Avascan Burned Fees
        • SnowTrace
          • SnowTrace Connector
          • Get ERC-20 Balance For Contract
          • Get ERC-20 Token Supply
          • Get Total AVAX on C-Chain
          • Get AVAX Balance Single Address
      • Binance Smart Chain
        • Network Blocks
          • Binance Smart Chain Connector
          • On Binance Smart Chain Block
          • On Binance Smart Chain Transaction
          • On Binance Smart Chain Wallet Transaction
        • BEP20 Blocks
          • Create BEP20 Token
          • Deploy BEP20 Token
      • Elrond
        • Elrond Connector
        • Get Elrond HyperBlock By Hash
        • Get Elrond Transaction
        • Get Elrond Wallet Balance
      • Ethereum
        • Ethereum Connector
        • On Ethereum Block
        • On Ethereum Transaction
        • On Ethereum Wallet Transaction
        • Estimate Gas Price
        • Get Ether Balance
        • Get Block Parameters
        • Get Transaction Parameters
        • Etherscan
          • Etherscan Connector
          • Etherscan Get Gas Price
        • Ethereum Managed Wallet
          • Get Personal Managed Wallet
        • Ethereum ERC20
          • Get ERC20 Holders
          • Get ERC20 Balance
          • Get ERC20 Information
          • Create ERC20 Token
          • Deploy ERC20 Token
        • Ethereum NFT
          • Create NFT Contract
          • Deploy NFT Contact
          • Create New Mintable NFT Token
          • Deploy New Mintable NFT Token
      • Polygon
        • Polygon Connector
      • Quickswap
        • Get Quickswap Pair Price
        • Get Quickswap Token Price
        • Get Quickswap LP Token
        • Get Quickswap LP Token Price
        • On Quickswap Swap
        • On Quickswap Sync
      • Unicrypt
        • Get Unicrypt Locked Token Parameters
        • Get Unicrypt Locked Tokens
        • Get Unicrypt Total Locked Liquidity
        • Get Unicrypt All LP Locked Tokens Address
        • On Unicrypt Deposit
      • Uniswap
        • Get Uniswap LP Token
        • Get Uniswap LP Token Price
        • Uniswap Get Pair Price
        • Get Uniswap Token Price
        • On Uniswap Swap
        • On Uniswap Sync
      • Solana
    • Blocks (Charting)
      • Generate Time Series One Line Chart
      • Generate Time Series Two Line Chart
    • Blocks (Machine Learning)
      • Spam Detection
      • Sentiment Analysis
    • Node Connector Colors
      • Strings & Variables
      • Execution Logic (Yellow)
      • Integers (orange)
      • Booleans (pink)
    • Block Execution Order
      • Additional Block Execution
    • Block Color
      • Colors & Meaning
    • Block Type Overview
      • Function Type
      • Entry Point Type
      • Event Trigger Type
      • Variable Type
      • Condition Type
      • Connector Type
  • Nocode Users
    • Instant Deploy Wizard
    • GraphLinq Marketplace
  • Twitter
  • Medium
  • Github
  • GraphLinq Explorer
  • Audit Report
Powered by GitBook
On this page
  • Block Description
  • Input Parameters
  • Output
  • Example Use Case
  • More Information
  • Full Example
  1. Dev tooling
  2. Blocks
  3. Math

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.

Block Description

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.

Input Parameters

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.

Output

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.

Example Use Case

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.


More Information

Use Case

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.

Example

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.


Full Example

Subtract A - B blocks subtract one given number from another, and then output the result.

Subtract A - B blocks 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).

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.

Note that the yellow executive output on the Get CoinGecko Coin block is plugged directly into the Print block, which means that this is the next block to be called after the Get CoinGecko Coin block. However, for the Print block to execute, its "Message" parameter must be supplied with a value. This causes the Replace String In Stringblock to resolve, which in turn causes the Subtract A - B block 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.

PreviousMathNextAdd A + B

Last updated 1 year ago

The 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.

In this example, the block efficiently calculates the subtraction operation and produces the desired output of 5.

As with all block types in the category, Subtract A - B blocks 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 graph has two parts. The part in the upper-left quadrant is an initialization structure. When the graph starts, we use a block to get the price of GLQ, and then we save it in a variable called "lastPrice" with a block.

The rest of the graph is driven by a Timer block, which fires every 5 minutes (300 seconds). Whenever it fires, it calls a Get CoinGecko Coin block, which retrieves the current price of GLQ. This price is then passed to our Subtract A - B block, which substracts from it the price from 5 minutes before (stored in the variable "lastPrice"). The output of our Subtract A - B block is thus the 5-minute price delta of GLQ. We pack this into a short message using a block and then print it into the graph's log using a block. Finally, we use a Set variable block to assign the current price of GLQ to the variable "lastPrice", so that when the Timer block next fires in 5 minutes, that variable will contain the 5-minute-old price of GLQ.

Subtract A - B
Subtract A - B
Math
Get CoinGecko Coin
Set variable
Replace String In String
Print