在第四章讲bitset时,有这么一段:
// start at position 6, for a length of 4: 1010
string bitval( "1111110101100011010101" );
bitset< 32 > bitvec5( bitval, 6, 4 );
bitvec5 is initialized with bit positions 1 and 3 set to 1 while its remaining bit positions are set to 0, the same as bitvec3 and bitvec4. If we leave off the third parameter indicating the length of characters with which to the range, the range consists of the indicated position to the end of the string. For example:
// start at position 6, continuing to end of string: 1010101
string bitval( "1111110101100011010101" );
bitset< 32 > bitvec6( bitval, 6 );
按照作者给出的结果:1010、1010101,第6位是从后往前数的?不知我理解的是否有误。
而我跟踪的结果是:1011、101100011010101。也就是说,第6位是从前往后数的。
大家怎么看?
// start at position 6, for a length of 4: 1010
string bitval( "1111110101100011010101" );
bitset< 32 > bitvec5( bitval, 6, 4 );
bitvec5 is initialized with bit positions 1 and 3 set to 1 while its remaining bit positions are set to 0, the same as bitvec3 and bitvec4. If we leave off the third parameter indicating the length of characters with which to the range, the range consists of the indicated position to the end of the string. For example:
// start at position 6, continuing to end of string: 1010101
string bitval( "1111110101100011010101" );
bitset< 32 > bitvec6( bitval, 6 );
按照作者给出的结果:1010、1010101,第6位是从后往前数的?不知我理解的是否有误。
而我跟踪的结果是:1011、101100011010101。也就是说,第6位是从前往后数的。
大家怎么看?
谢谢你的回复,不过你没看清我的问题,我当然知道是从0开始的。
谢谢你的回复,不过你没看清我的问题,我当然知道是从0开始的。