Cyclic Nature of a Data type

what is meaning of cyclic nature of the data type ?
 
Ans:


In the data type char ,int,long int if we assign the value beyond range of of data type instead of giving compiler error it repeat the same value in cyclic order.
unsigned char : Range of unsigned char is 0 to 255 .




If we will assign a value greater than 255 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number.If number is less than 0 then move anti clockwise direction.
If number is X where X is greater than 255 then
New value = X % 256
If number is Y where Y is less than 0 then
New value = 256 – ( Y% 256 )
signed char :
Range of unsigned char is -128 to 127 .



If we will assign a value greater than 127 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than -128 then move anti clockwise direction.
If number is X where X is greater than 127 then
p = X % 256
if p <=127 new value = p else new value = p - 256 If number is Y where Y is less than -128 then p = Y % 256 If p <= 127 New value = -p else New value = 256 -p
unsigned int :
Range of unsigned int is 0 to 653535 .


If we will assign a value greater than 65535 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number.If number is less than 0 then move anti clockwise direction.
If number is X where X is greater than 65535 then
New value = X % 65536
If number is Y where Y is less than 0 then
New value = 65536– ( Y% 65536)
signed int :
Range of unsigned int is -32768 to 32767 .


If we will assign a value greater than 32767 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than -32768 then move anti clockwise direction.
If number is X where X is greater than 32767 then
p = X % 65536
if p <=32767 new value = p else new value = p - 65536 If number is Y where Y is less than -32768 then p = Y % 65536 If p <= 32767 New value = -p else New value = 65536 -p
Same thing is occurred in case of signed long int and unsigned long int


0 comments:

Post a Comment