consensus-specs icon indicating copy to clipboard operation
consensus-specs copied to clipboard

Simplify spec by adding safe math functions

Open vbuterin opened this issue 5 years ago • 0 comments

The two that immediately come to mind, with multiple use cases already in the spec, are:

def safe_modulo_subtract(a, b, modulus):
    return (a + modulus - b) % modulus

def safe_a_mul_b_div_c(a, b, c, increment):
    return (a // increment) * b // (c // increment)

vbuterin avatar Oct 01 '20 12:10 vbuterin