Pow implementation

This commit is contained in:
Tomusdrw 2016-01-15 14:45:30 +01:00
parent c4e5271651
commit 5e2721f964

View File

@ -335,8 +335,8 @@ impl Interpreter {
},
instructions::EXP => {
let expon = stack.peek(1);
// TODO [todr] not sure how to calculate that
let gas = U256::from(schedule.exp_gas);
let first_bits = (expon.byte(0) / 8) as usize;
let gas = U256::from(schedule.exp_gas + schedule.exp_byte_gas * (32 - first_bits));
InstructionCost::Gas(gas)
},
_ => InstructionCost::Gas(default_gas)
@ -759,7 +759,7 @@ impl Interpreter {
instructions::EXP => {
let base = stack.pop_back();
let expon = stack.pop_back();
stack.push(u256_pow(base, expon));
stack.push(base.pow(expon));
},
instructions::NOT => {
let a = stack.pop_back();
@ -884,11 +884,6 @@ impl Interpreter {
}
fn u256_pow(value: U256, expon: U256) -> U256 {
// TODO implement me!
U256::zero()
}
fn get_and_reset_sign(value: U256) -> (U256, bool) {
let sign = value.bit(255);
(set_sign(value, false), sign)