3

I'm using the PRBMath fixed-point math library:

The library contains the following line:

uint256 internal constant SCALE_INVERSE =     78156646155174841979727994598816262306175212592076161876661_508869554232690281;

Can someone please explain the purpose of the underscore here, and why is it allowed in an integer?

2

2 Answers 2

2

Like in many other programming languages you can use underscores to improve the readability of large numbers. As written in the Solidity docs:

Underscores can be used to separate the digits of a numeric literal to aid readability.

0

The underscore is indeed for readability. In Solidity, you can use underscores as separators within numeric literals to make them easier to read.

For example:

The value 100_000 is equivalent to 100000. The underscores have no impact on the actual value of the number and are simply ignored by the compiler. This feature is helpful when working with large numbers, as it makes it easier to distinguish between different orders of magnitude.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.