There seems to be a problem with the bitset function for uint64. Here is a simple example:

>> d = 38124631952277504;

>> dec2bin(d)

ans =

'10000111011100100010011010011000101101010100000000000000'

>> dec2bin(d+1)

ans =

'10000111011100100010011010011000101101010100000000000000'

>> dec2bin(bitset(d,1,'uint64'))

ans =

'10000111011100100010011010011000101101010100000000000000'

>> dec2bin(bitset(d,2,'uint64'))

ans =

'10000111011100100010011010011000101101010100000000000000'

>> dec2bin(bitset(d,3,'uint64'))

ans =

'10000111011100100010011010011000101101010100000000000000'

>> dec2bin(bitset(d,4,'uint64'))

ans =

'10000111011100100010011010011000101101010100000000001000'

>> dec2bin(d+8)

ans =

'10000111011100100010011010011000101101010100000000001000'

So the bits only change successfully from 4th bit on, but fail to set fo the first three bits. This makes no sense that I can see and seems to be a serious error in Matlab.

Any help would be appreciated. Or advice on how to alert Matlab engineers.

Thanks,

Jason

## Best Answer