Ethereum Vyper Uchebnik: Ponimania //
syntax
As a programist, using vyper for the inteling disinfecting counteract, you can stir with the following scoring at the resting of the operation:
`
Invalidididoplation: ten -section on uint256 can’t be out
`
This problem appears to be that the Waper does not suck the tenth arithmetic. Failing of the two -scales uint256 'in vyper 0.4.0b or more new, this brittle exclusion" invasioptation ".
in what is a spinning of the intercourse//and
(pre -form)?
B vyper is two syntaxis for converses:
- // Convert ()
:
- This method is retained by converted value.
- Odin argument is not necessary (values ​​for the pre -formation) and the new "Uint256" will be recovered.
- If you use the operator of the divyia (/) or the operator Modulo (
%), this can release the problems from the indifference of the nomen from the floating.
- (convert (shada, uint25)*…
:
- This method is adopted by two arguments: values ​​(in the quality of the strokes) and a mud.
- He is asked to interfere with the string inuint256, and to think of her on a given amount.
- Vyper 0.4.0b or late this syntaxis is recommended for the tenth.
How to solve the problem
To relinze the scorching of the operation of the work in vyper:
1.
At the time of two bids
`V
DIV (Result, 10); // Prefal that "Result" is a substantial, uttering one from the spine
- Follow Uspolzing
// Convert ()
in the ten -section
As the wound is wounded, Vyper does not succeed in the tenth arithmetic, the method “//”. Aside this use (convert (shadow, uint256) * ...
.
Primer Uspolzing: Tsesetic section
To prodigonstrate this underwear, let’s make a simple prime:
`V
Counter -Mathematics {
Breated function (A: U32, B: U8) Public pure phrases (U32) {
Return (A / Conwer (B, U256)) % 10; // Using the converted value for the most
}
}
In this fragmentation code:
– pre -formation (1, 2)
– this is the function of the pre -formation, which interuses the stack in uint256
. The “pre -formation” method can be encompassed as “U32” and “U8”, which makes it possible for our receiver.
– in the function “sectioning” (pre -formation (B, U256)) provides the tenative arithmetic on the improving the potential fractional part
b.
- We do it, using the pre -emptive value:A / (pre -form (B, U256)) % 10.
Enjoyment
In this state, we dissatisfied, why the viper brings the "Invvalididia" exclusion in the time of the tenth. Ponimania, as it is rightly pre -empting and using the recommended syntax(convert (shada, uint256)) * …`