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
  • More Information
  • Full Example
  1. Dev tooling
  2. Blocks
  3. Math

Round

Round numeric values to the nearest integer or to a specific number of decimal places

The Round block in the GraphLinq IDE is a fundamental mathematical tool used to round numeric values to the nearest integer or to a specific number of decimal places. This block is invaluable for formatting numerical data and ensuring it aligns with desired precision levels.

Block Description

The Round block is part of the Math blocks category in the GraphLinq IDE. As with other blocks in this category, it is a non-executive block, which means it lacks yellow connectors and is implicitly called when other blocks require its output during graph execution.

Input Parameters

The Round block requires two input parameters:

  1. Number (Numeric Type): The Number input represents the numeric value that needs to be rounded.

  2. Decimal Places (Integer Type): The Decimal Places input specifies the number of decimal places to which the value should be rounded. If this parameter is omitted, the block will round the number to the nearest integer.

Output

The Round block outputs the rounded numeric value based on the provided input. The output will be an integer when the Decimal Places parameter is not provided, and a decimal number when the Decimal Places parameter is used to specify the precision level.

Example Use Case: Let's examine a practical example of how the Round block can be utilized in a graph:

  1. The graph calculates the average temperature of a location and stores the result in a variable called AverageTemperature.

  2. The Round block is invoked, taking AverageTemperature as the input number and specifying the desired precision level using the Decimal Places parameter.

  3. The block rounds the average temperature to the specified number of decimal places, ensuring that the temperature value is presented with the appropriate level of precision.

  4. The output represents the rounded temperature value, which can be used for display or further computations.

In this example, the Round block allows the graph to format the average temperature data, ensuring it is presented in a visually pleasing and meaningful way to users or other downstream processes.

The Round block is a versatile mathematical tool within the GraphLinq IDE, providing the capability to round numeric values to the nearest integer or to a specific number of decimal places. Its usefulness extends across various domains, including financial applications, data analysis, and user interface development. By utilizing the Round block, developers can ensure that numeric data aligns with desired precision levels, enhancing the overall quality and readability of the graph's output.


More Information

The Round block in the GraphLinq IDE is a fundamental mathematical component used to round a given numeric value "A" to the nearest whole number or a specified number of decimal places. It provides a convenient method to adjust the precision of numeric data, ensuring that the output conforms to the desired level of accuracy.

Block Details

The Round block takes two input parameters: "A" and "Decimal Places." "A" represents the numeric value that needs to be rounded, and "Decimal Places" is an optional parameter that allows developers to specify the number of decimal places to which the value should be rounded. If "Decimal Places" is not provided, the block rounds "A" to the nearest whole number.

Execution

Like other blocks in the Math category, the Round block is non-executive, meaning it does not have yellow connectors. Instead, it is implicitly called whenever its output is needed as input by other executing blocks. When the Round block's output is required in a graph, it performs the rounding operation on the input value "A" and delivers the rounded result as its output.

Use Case

The Round block finds extensive applications in various scenarios where precision in numeric data is critical. It is commonly used in financial calculations, statistical analyses, and data visualizations. For instance, in financial applications, rounding is essential for representing monetary values in a standardized format. In statistics, rounding data helps maintain a consistent level of significance across datasets. In data visualizations, rounded values improve readability and eliminate unnecessary detail.

Example

Let's consider an example to illustrate the usage of the Round block. Suppose we have a graph that calculates the average temperature for a given day, based on hourly temperature measurements. The graph takes the sum of hourly temperatures (A) and the number of measurements (B) as inputs and needs to compute the average temperature.

To achieve this, we first use the Divide A / B block to calculate the average temperature, which might result in a decimal value with multiple decimal places. However, for display purposes, we want to round the average temperature to two decimal places.

To achieve the desired rounding, we can use the Round block with "Decimal Places" set to 2. By providing the calculated average temperature to the Round block and specifying "2" for the "Decimal Places" parameter, the block rounds the value to two decimal places and outputs the rounded average temperature.

The Round block's ability to round numeric values to a specified precision enables developers to control the level of detail in their graphs' outputs. It enhances the presentation of numeric data and ensures that calculations conform to the desired level of accuracy.


Full Example

Round blocks are used to round a given decimal number to a given degree of precision.

Round blocks have two input parameters: "Number", which is the number we would like to have rounded, and which should be a decimal type value, and "Decimal", which (somewhat confusingly) is an integer that represents how many digits of precision we would like to the right of the decimal point.

PreviousPercentage DifferenceNextHTTP

Last updated 1 year ago

As with all block types in the category, Round 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.

In this example, we are using a Discord bot that we control in conjunction with a block to listen to our Discord channel for the message "/matic_price". When we detect that someone has sent that message, we use a block to retrieve the current price of the Matic token. We then use our Round block to round the price to 3 digits of precision (for example, $1.124) before adding it into a short message using a block and then submitting that message to our Discord channel with our bot using a block.

Math
String Branch
Get CoinGecko Coin
Replace String In String
Send Discord Channel Message