MCPcopy
hub / github.com/ethereum/EIPs / add_helper

Function add_helper

assets/eip-7543/decimal_float.go:377–388  ·  view source on GitHub ↗

out = {c: d1.c, q: 10^max(d1.q - d2.q, 0)}

(d1, d2 *Decimal, gas *uint64)

Source from the content-addressed store, hash-verified

375
376// out = {c: d1.c, q: 10^max(d1.q - d2.q, 0)}
377func add_helper(d1, d2 *Decimal, gas *uint64) (out int256) {
378 var exponent_diff int256
379 Sub(&d1.q, &d2.q, &exponent_diff, gas)
380 if Sign(&exponent_diff, gas) == -1 {
381 exponent_diff = *ZERO_INT256 // shallow copy ok
382 }
383
384 Exp(TEN_INT256, &exponent_diff, &out, gas)
385 Mul(&d1.c, &out, &out, gas)
386
387 return out
388}
389
390// remove trailing zeros from coefficient
391func find_num_trailing_zeros_signed_DECIMAL256(a *int256, gas *uint64) (p, ten_power *int256) {

Callers 1

AddMethod · 0.85

Calls 4

SubFunction · 0.85
SignFunction · 0.85
ExpFunction · 0.85
MulFunction · 0.85

Tested by

no test coverage detected