mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix number representation bug.
This commit is contained in:
parent
e2f00c96d5
commit
5c4f3f6d0b
@ -18,6 +18,7 @@ Bugfixes:
|
||||
and source mappings.
|
||||
* Gas Estimator: Reflect the most recent fee schedule.
|
||||
* Type system: Contract inheriting from base with unimplemented constructor should be abstract.
|
||||
* Optimizer: Number representation bug in the constant optimizer fixed.
|
||||
|
||||
### 0.4.10 (2017-03-15)
|
||||
|
||||
|
@ -203,8 +203,13 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
|
||||
u256 powerOfTwo = u256(1) << bits;
|
||||
u256 upperPart = _value >> bits;
|
||||
bigint lowerPart = _value & (powerOfTwo - 1);
|
||||
if (abs(powerOfTwo - lowerPart) < lowerPart)
|
||||
if (powerOfTwo - lowerPart < lowerPart)
|
||||
{
|
||||
lowerPart = lowerPart - powerOfTwo; // make it negative
|
||||
upperPart++;
|
||||
}
|
||||
if (upperPart == 0)
|
||||
continue;
|
||||
if (abs(lowerPart) >= (powerOfTwo >> 8))
|
||||
continue;
|
||||
|
||||
@ -212,7 +217,7 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
|
||||
if (lowerPart != 0)
|
||||
newRoutine += findRepresentation(u256(abs(lowerPart)));
|
||||
newRoutine += AssemblyItems{u256(bits), u256(2), Instruction::EXP};
|
||||
if (upperPart != 1 && upperPart != 0)
|
||||
if (upperPart != 1)
|
||||
newRoutine += findRepresentation(upperPart) + AssemblyItems{Instruction::MUL};
|
||||
if (lowerPart > 0)
|
||||
newRoutine += AssemblyItems{Instruction::ADD};
|
||||
|
Loading…
Reference in New Issue
Block a user