Search
K
Comment on page

Decimal

The Decimal block in the GraphLinq IDE allows manipulation of fractional values, also known as decimal numbers. Decimal numbers are used to represent values with a higher precision than whole numbers (integers). They are essential for performing calculations that involve fractional parts.

Input Parameters

The Decimal block does not have any inputs. Instead, it serves as a static value block that can be connected to other blocks in a graph.

Output

The Decimal block has one output parameter that represents the decimal value. This output can be connected to other blocks that accept decimal values as input.

Usage

The Decimal block is used in various mathematical operations within a graph. It can represent quantities like currency, measurements, and percentages accurately. Additionally, the Decimal block is often used in conjunction with other math blocks to perform complex arithmetic calculations.

Examples

Performing Arithmetic Operations

Suppose a graph needs to calculate the total cost of items in a shopping cart, including tax. The graph may use Decimal blocks to represent the item prices, tax rate, and the total cost.
Input (Decimal):
Item Price: \$10.99
Tax Rate: 0.08 (8%)
By connecting the Decimal blocks to an Add A + B block, the graph can calculate the total cost, including tax.
Output (Decimal):
Total Cost: \$11.87

Handeling Financial Transactions

In a financial application, the Decimal block can be used to represent currency values accurately. For example, a graph could calculate the interest accrued on a loan using decimal values for principal amount, interest rate, and time.
Input (Decimal):
Principal Amount: \$1000.00
Interest Rate: 0.05 (5%)
Time: 2 years
By connecting the Decimal blocks to a Multiply A * B block and a Multiply A * B block, the graph can calculate the total interest and the final amount.
Output (Decimal):
Total Interest: \$100.00
Final Amount: \$1100.00
Note: The Decimal block is a versatile tool for working with fractional values and performing precise calculations. By using Decimal blocks in combination with other math blocks, developers can build graphs that handle various financial, scientific, and engineering calculations with accuracy and efficiency.

As with all the other base variable data types, we can also save decimal values determined at runtime as persistent variables using `Set variable` blocks, and we can retrieve those values later using `Get variable` blocks.