Ethereum: How multiplication and division works in solidity?

Ethereum: How Multiplication and Share Work in Strength

============================================ ==== ============ ==== =======================

In the case of holiness, the order of operations is crucial for accurate calculations. Two general arithmetic operations that can cause confusion, multiplication and sharing. In this article, we examine how these operations work with strength, especially with regard to being calculated.

The priority and order of surgery

—————————–

Strength follows a specific rule of priority on arithmetic operations:

1 Candle: First appreciate the phrases in parentheses.

  • Exponents (eg **): Evaluate all exponents as follows.

3

  • Concence and subtraction (for example, 5 + 3): Add order to subtract.

Examine the specified example:

`Solidity

Quantity = (15-10) 10/15 (10000 - 5000) / 10000;

If we reduce this term, we can follow the priorang rules:

1.

* 15-10 = 5 (exposure is not applicable)

* 10000 - 5000 = 5000" (exponentation is not applicable)

  • Multiply “5” to '10:5 * 10 = 50

3 .. Share the "50" up toto ’15:50/15 = 3.333 ...

  • Finally, multiply the result (5000/1000): : (3.333 …) * (5) = 16.666 …

The correct calculation in fact:

Quantity = 50/15 * 5000/1000;

`

No `5 * 10/15.

Frequent errors

—————–

To avoid the usual errors when they work with arithmetic operations of strength:

  • Always evaluate the phrases in parentheses.

  • Pay attention to exponents (such as **) and make sure you perform the operation correctly.

3

The best practices

—————–

Writing an accurate and efficient strength code:

  • Use brackets for group operations for clarity.

  • Carefully follow the order of priority rules.

  • Pay attention to exposure (such as **) when you make calculations that affect a large number or exponential growth.

If you understand how multiplication and class works with strength, you can write more accurate and reliable intelligent contracts that use the unique functions of the language.

Ethereum Binance Balance

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat
Hello 👋
Can we help you?