Wednesday, 13 March 2013

Unusual behaviour of signed and unsigned modifier

Signed and unsigned modifiers are not compatible with float and double.But if we use them with double and float there is only display an intellisense error and when we compile the program ,it shows nothing as an error.So we should be attentive while using signed and unsigned because compiler shows nothing as an error and compiler takes something as a default.Here is a program to describe the behaviour of signed and unsigned :-



 Here we can see that when signed and unsigned float printed as a float it gives zero.Similarly in the case of signed and unsigned double it also returns zero.Here we can seen one more thing that the value of integer a when printed as a float then it also returns zero.It means we must never use an integer as float.

No comments:

Post a Comment