Changing integer to binary string of digits

后端 未结 5 1019
梦毁少年i
梦毁少年i 2020-12-15 04:24

I\'m currently working on a simulation of the MIPS processor in C++ for a comp architecture class and having some problems converting from decimal numbers to binary (signed

5条回答
  •  盖世英雄少女心
    2020-12-15 04:52

    Replace:

    if((mask&a) >= 1)
    

    with either:

    if ((mask & a) != 0)
    

    or:

    if (mask & a)
    

    Your problem is that the last bit gives you a negative number, not a positive one.

提交回复
热议问题