# Solidity Docs Code Example divide by two then require multiply quotient by two

The below is right from the solidity readTheDocs page. Its from the Safe Remote Purchase section on https://solidity.readthedocs.io/en/develop/solidity-by-example.html#micropayment-channel.

function Purchase() payable {
seller = msg.sender;
value = msg.value / 2;
require((2 * value) == msg.value);
}

What are the last two lines doing? Dividing the value by two and then requiring that the inverse must be equal to the original number. What's the point? I must be missing something.

## 1 Answer

Solidity only allows for integer arithmetic. So if you have an odd number and divide it by 2, it will truncate the decimal. Re-multiplying by 2 at that point would not give you back the same number. So the require statement essentially verifies that the number of wei sent is an even number.

• ok, so it's no wonder it doesn't make sense in the context of this contract. It didn't mention anywhere that only even payments are accepted. – jyapx Jun 17 '17 at 19:16