VIP: epsilon(decimal)
builtin for decimal types
#2992
Labels
Easy Pickings
Used to denote issues that should be easy to implement
help wanted
VIP: Approved
VIP Approved
Simple Summary
Add an
epsilon()
builtin which returns the smallest non-zero value for a decimal type.Motivation
Similar to #1923, it is nice to not have to type out these special constants (as is done for instance here: https://github.com/vyperlang/vyper/pull/2935/files#diff-86a0306fe1e101309bd0992f2780ec4f0c3dd319940131270904157845c9d9beR79)
Specification
Add an
epsilon()
builtin which takes adecimal
typedef as its argument, and returns the smallest non-zero value for that type. Currently as we only have one decimal type, this would beepsilon(decimal) == 1e-10
. In general as we add more decimal types,epsilon(Decimal[N, ...])
would return1 / 10**N
. This is already in the typeinfo for decimals, it's just a matter of exposing as a builtinvyper/vyper/codegen/types/types.py
Lines 110 to 112 in 9a02a44
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: