1

I don't know how to correct the code of function 4 & 5.

pragma solidity ^0.4.4;


contract C {
    bytes1 b10 = 0x6c;// l-> 0110 1100 6c转换为10进制-》12*16^0+6*16^1=108
    bytes1 b11 = 0x69;

    function test1() constant returns (bytes1) {
        return b10 & b11; 

    }

    function test2() constant returns (bytes1) {
        return b10 | b11; //或 
         //0110 1100 ->0x6c
         //0110 1001->0x69 
        // 0110 1101(上下10对应的时候是1真)->0x6d
    }

    function test3() constant returns (bytes1) {
        return ~b10;  
         //0110 1100 ->0x6c
         //->1001 0011 ->0x93
    }

    **function test4() constant returns (bytes1) {
        return b10 << 1;  
         //0110 1100 ->0x6c
         //->1101 1000->0xd8
    }
    function test5() constant returns (bytes1) {
        return b10 >> 1;  
         //0110 1100 ->0x6c
         //->0011 0110->0x36 
    }**

}
  • You are using a very old compiler v0.4.4 is from 2016. That error and many others were fixed in newer versions. I'd suggest to use at least 0.4.26. – Ismael Aug 10 at 17:07
  • thanks a lot it works with 0.4.26;!!! – YwD Aug 12 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.