开发者

How do I get the 48 least significant bits of a long formatted as hex?

long number = …;

// string should contain exactly 12 characters
string leastSignificant48bitsOfNumberAsHex = nu开发者_如何学JAVAmber.ToString("????")


You can do it with string formatting:

string leastSignificant48bitsOfNumberAsHex = String.Format("{0:X012}", number & 0xFFFFFFFFFFFF);

This will fill up the string with zeroes if the number is shorter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜