I assume you meant 0xff0000AA
, as others have pointed out, 0xff00000AA
is an overflow.
The easiest way to do this is to convert the value from a string. You can use System.Convert
:
[System.Convert]::ToUInt32('0xff0000AA',16) [System.Convert]::ToUInt32('ff0000AA',16)
Or just try specifying a string, but in this case you need to add 0x
:
[uint32]'0xff0000AA'
If, on the other hand, you really wanted to know the 32-bit unsigned integer part of the 64-bit number "0xff00000aa", you could do this:
[System.Convert]::ToUInt32([System.Convert]::ToString(0xff00000AA -band ([uint32]::MaxValue),16),16)
source share