开发者

Specifics about shifting floating point data types in .Net?

If I remember right, a double or float is broken into 3 parts: a sign bit, the exponent, and the m开发者_如何学运维antissa.

When a double is shifted, do the bits shift the entire binary of the variable or does it just shift the mantissa?


You can't shift floating point types - in C# at least.

On the other hand, if you were to multiply or divide by two repeatedly, you'd see what I mentioned before: within the range of normalized numbers, shifting left would increase the exponent by one and shifting right would decrease the exponent by one. Within denormal numbers, the exponent is fixed at 0, so the mantissa has to change.

EDIT: To answer your comment, a value represents a subnormal/denormal number if the exponent is zero and the mantissa is non-zero. See this page for more information on IEEE 754 in general, and I have a page on .NET binary floating point.


As far as I know, shift operators are only defined on Integers in .Net.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜