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

Ceiling

Round a numeric value up to the nearest integer greater than or equal to the original value

The Ceiling block in the GraphLinq IDE is a powerful mathematical tool used to round a numeric value up to the nearest integer greater than or equal to the original value. This block is particularly useful when precision is not required, and developers need to ensure that a value is always rounded up to the nearest whole number or integer.

Block Description

The Ceiling block is categorized under the Math blocks 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 whenever its output is needed as input by other blocks during graph execution.

Input Parameter

The Ceiling block requires one input parameter:

  1. A (Numeric Type): The A input represents the numeric value that needs to be rounded up to the nearest integer.

The A input can accept various numeric data types, such as decimals, integers, and longs.

Output

The Ceiling block outputs the result of rounding up the input value A to the nearest integer greater than or equal to A. The output is of the same data type as the input value.

Example Use Case

Let's explore a practical example of how the Ceiling block can be used within a graph to ensure that a calculated value is always rounded up to the nearest whole number.

  1. The graph performs various complex calculations, resulting in a numeric value (e.g., 34.75, 11.35, etc.).

  2. The Ceiling block is called, taking the calculated numeric value as input A.

  3. The block rounds up the value to the nearest integer greater than or equal to the original value.

  4. The resulting rounded-up value (e.g., 35, 12) is further used in subsequent calculations or to display data in the graph's output.

In this example, the Ceiling block ensures that the calculated numeric value is always rounded up to the nearest whole number, even if the original value contains decimal places. This rounding behavior can be beneficial in various scenarios, such as calculating quantities for inventory management, displaying rounded data in user interfaces, or ensuring proper billing amounts in financial applications.

Conclusion

The Ceiling block provides a straightforward and effective solution for rounding numeric values up to the nearest integer in the GraphLinq IDE. By using this block, developers can ensure that a value is always rounded up, regardless of its decimal precision. Whether it's for simplifying complex calculations or ensuring data consistency, the Ceiling block proves to be a valuable tool in achieving precise and predictable rounding outcomes.


More Information

The Ceiling block in the GraphLinq IDE is a powerful mathematical tool used to round up a numeric value to the nearest integer greater than or equal to that value. This block is particularly useful when precision is required in numeric calculations, ensuring that values are rounded up to the desired level of accuracy.

Block Details

The Ceiling block takes a single input parameter, "A," which represents the numeric value that needs to be rounded up. This input can accept various types of numeric data, such as decimal, integer, or long. The Ceiling block's output is the rounded-up integer result of the input value.

Execution

Like other block types in the Math category, the Ceiling block is a non-executive block. It does not have yellow connectors and is not directly called by other blocks. Instead, it is implicitly called whenever its output is required as input by other executing blocks.

Use Case

The Ceiling block is essential in situations where precise rounding of numeric values is required. It is commonly used in financial applications, pricing calculations, and scenarios where data needs to be presented in a clear and consistent format. For example, in e-commerce applications, the Ceiling block can be used to round up product prices to the nearest whole number or a specific decimal place, ensuring consistent and accurate pricing.

Example

Let's consider an example to demonstrate the functionality of the Ceiling block. Suppose we have a graph that calculates the total cost of purchasing a specific quantity of items. The graph takes inputs "Unit Price" and "Quantity," representing the price of each item and the desired quantity to purchase, respectively.

To determine the total cost, we need to multiply the unit price by the quantity. However, in certain scenarios, the unit price may have decimal places, and we want to ensure that the total cost is rounded up to the nearest whole number. Here, we can use the Ceiling block to round up the calculated total cost.

The Ceiling block takes the product of the unit price and quantity as input and rounds it up to the nearest integer, representing the total cost of the purchase. This ensures that the total cost is always rounded up to the desired level of accuracy, even if the unit price has fractional values.

By utilizing the Ceiling block, developers can perform precise rounding of numeric values within their graphs, ensuring that calculations and data processing tasks are accurate and reliable. The Ceiling block is an essential tool for maintaining consistency and precision in numerical operations, making it a valuable asset in various applications across industries.


Full Example

Ceiling blocks only have one input parameter called "Number", which is the number that we would like to round up. The logical data type for this parameter is decimal.

In the example above, we are simply calculating and printing the lowest amount of entire Bitcoins worth at least $1 million at the current market price as per CoinGecko.

PreviousAdd A + BNextDivide A / B

Last updated 1 year ago

Ceiling blocks are used to round numbers up to the nearest integer. They are very similar to blocks; the only difference between the two is that Ceiling blocks round up (so 5.01 -> 6), whereas Floor blocks round down (so 5.99 -> 5).

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

We use a block to fetch the price of Bitcoin once when the graph begins its execution. We then divide 1 million by the current price of Bitcoin using a block. This gives us the true amount of Bitcoin which is equivalent to $1 million dollars. For example, if BTC currently costs $35,000, this calculation would result in 28.57 BTC. However, we want the lowest amount of the whole BTC worth at least $1 million, which is where our Ceiling block comes in. Once we ceiling this value, we get 29, which is then packed into a short message using a block, and recorded in the graph's logs with a block.

Note that the yellow executive output on the 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 Ceiling block to resolve (which then causes the Divide 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.

Floor
Math
Get CoinGecko Coin
Divide A / B
Replace String In String
Print
Get CoinGecko Coin