It's a concrete way of representing a part of a whole with precisionmore or less resolution.
As you point out when you use any of the per_things structs, what you are expressing a part of a whole.
In case of percent ( as you might be more used to) when you refer to 100%, that's the unit, the total of the whole. So 100 out of 100 parts, that is the whole amount of units, which is the 100%. This way you can do a division of something in 100 parts and you can express a subset of it, being the half (50 parts out of 100 parts in this case) 50% and so on.
Example time! - Imagine you have cake:
If you want to divide the cake (the whole/ the unit) in 25 parts and you want to express it in percent terms, having 10 parts would be the 40% of the cake.
Then, if for your use case happens to need higher precision for expressing a subset out of the whole you might go with something different than percent, that being perthousand, permill or perbill.
Then, going back to the cake example, if you divide it in 1 billion parts, the precision goes up, but you can still express a sub set of all the parts of the cake by saying, I have the Perbill::from_percent(40);
of the total of the cake. The amount of cake you have is the same than in the previous example, but is expressed with a crazy big precision for a cake (?)
If you check the documentation, you will see that Perbill::one() and Perbill::zero() exist. And as stated
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1]
Perbill::one()
will reference the total of the unit, all the parts of the cake.Perbill::zero()
will reference an empty set containing no parts at all from the total of parts.