@sanjay: some compilers do support them in c but standard c says its undefined.its left to compilers to implement the sign extenstion or not
On Sat, Aug 20, 2011 at 2:14 PM, Sanjay Rajpal <[email protected]> wrote: > There is one more thing about shift operators that I would like to add one > more thing, if instead of shifting to the left, if you shift to the right, > in case of negative numbers, '1' leftmost bit will be carried along with it. > > for e.g. o/p of this code is all Fs : > > #include > <stdio.h> > > #include > <stdlib.h> > > int main() > > { > > int x=-16; > > printf( > "%X\n",x >> 4); > > system("pause"); > > } > > Sanju > :) > > > > On Fri, Aug 19, 2011 at 11:28 PM, Vijay Khandar > <[email protected]>wrote: > >> >> Yes ans is fff0, my mistake......... >> >> On Sat, Aug 20, 2011 at 11:56 AM, sukran dhawan >> <[email protected]>wrote: >> >>> check o/p once.it shud be fff0 coz rightmost bits are filled with 0s >>> >>> >>> On Sat, Aug 20, 2011 at 11:56 AM, sukran dhawan >>> <[email protected]>wrote: >>> >>>> i got the answer as fff0 >>>> >>>> >>>> On Sat, Aug 20, 2011 at 11:55 AM, Vijay Khandar < >>>> [email protected]> wrote: >>>> >>>>> Thank you very much..........now i got it............. >>>>> >>>>> >>>>> On Sat, Aug 20, 2011 at 11:51 AM, Ayswarya Srinivasan < >>>>> [email protected]> wrote: >>>>> >>>>>> i guess the output is fff0 >>>>>> >>>>>> -1 = 0000 0000 0000 0001 >>>>>> taking 1's complement >>>>>> 1111 1111 1111 1110 >>>>>> taking 2's complement >>>>>> 1111 1111 1111 1111 >>>>>> -1<<4 >>>>>> left shifting 4 bits >>>>>> 1111 1111 1111 0000 >>>>>> >>>>>> %x prints in hexa decimal format >>>>>> so o/p- f f f 0 >>>>>> >>>>>> >>>>>> On Sat, Aug 20, 2011 at 11:39 AM, Vijay Khandar < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> main() >>>>>>> { >>>>>>> printf("\n %x",-1<<4); >>>>>>> } >>>>>>> >>>>>>> o/p-ffff >>>>>>> >>>>>>> Plz tell me anyone how this program is working? what is the meaning >>>>>>> of >>>>>>> -1<<4, 45>>6,-6<<65 etc.. how this statement is executed..........? >>>>>>> >>>>>>> Vijay............ >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Algorithm Geeks" group. >>>>>>> To post to this group, send email to [email protected]. >>>>>>> To unsubscribe from this group, send email to >>>>>>> [email protected]. >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Regards, >>>>>> Ayswarya S >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
