ÈçÌ⣬
¡¶pythonÔ´ÂëÆÊÎö¡·ÖеÚ32Ò³£¬
Óиö¼ì²é¼Ó·¨½á¹ûÊÇ·ñÒç³öµÄ´úÂ룬
´óÖÂÈçÏ£º
C/C++ code:
long a, b, x;
x = a + b;
//¼ì²é½á¹ûÊÇ·ñÒç³ö
if((x^a)>=0 || (x^b)>=0)
return OK; //ûÓÐÒæ´¦£¿
Çë½Ì£¬
ΪʲôÉÏÃæµÄÁ½¸öÒì»ò¿ÉÒÔÅжÏÊÇ·ñÒç³ö£¿
лл£¡£¡
ÎÒ¶¥
¼Ù¶¨longÊÇ32λ¡£x^aµÄ½á¹ûÊÇint£¬Ò²ÊÇ32λ¡£
Ê×ÏÈ£¬x^a>=0£¬ËµÃ÷x^aµÄ×î¸ßλbit31ÊÇ0£¬
Ò²¾ÍÊÇ˵£¬xºÍaµÄ×î¸ßλ¶¼ÊÇ1£¬»òÕ߶¼ÊÇ0
¼ÙÉ裬
ÎÒÃÇÓÃ4¸öbit±íʾÕûÊý¡£
ÔòÄܹ»±íʾµÄ·¶Î§ÊÇ-7µ½7£»
Ôò£¨-7£©+£¨-1£©= -8Ó¦¸ÃÒç³ö¡£
ÉÏʽµÄ¶þ½øÖƲ¹ÂëÊÇ£º
1001 + 1111 = 1000£»
µ«Õâʱ£¬
(1001)^(1000)=0001 >= 0
(1111)^(1000)=0111 >= 0
ÈôÉÏʽ²ÉÓò¹ÂëµÄ¼ÆËã¹ý³ÌÈç¹ûÕýÈ·£¬
ÔòÌâÄ¿Öеļì²éÒç³öµÄ·½·¨£¬»¹ÊÇÈÃÎÒÃÔ»ó¡£
ÁíÍ⣬Èç¹û²»Óò¹Â룬
Ôò£¬-1+1=0 µÄ¶þ½øÖƱíʾ¾Í³ÉÁË1001+0001=1010
»¹Çë´ó¼Ò¼ÌÐøÖ¸µã¡£
лл£¡£¡
Ïà¹ØÎÊ´ð£º
RT£¬Ã²ËÆPythonÖ®¸¸Ò²ËµÈç¹ûÄãÏÖÔÚ¿ªÊ¼ÐµÄÏîÄ¿µÄ»°£¬×îºÃÊÇÖ±½ÓʹÓÃPython3£¬¿ÉÊÇʵ¼ÊÉÏ´ó¼ÒʹÓõô󲿷ֻ¹ÊÇ2.5£¬¹À¼ÆÓÃ2.6µÄ¶¼²»ÊǺܶ࣬²¢ÇÒÏà¶ÔÓ¦µÄÐí¶àÀ©Õ¹¶¼Ã»ÓÐ3¶ÔÓ¦µÄ°æ±¾¡£
  ......
ÎÒÓÃÁËdef CreateMyDialog(self):
dlg = MyDialog(None, -1, ''.decode('utf8'), (300,300), (300,200), wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_NO_PARENT )
&nbs ......
ʹÓÃÔ´Îļþ
#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'
ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......
python "$cur_path/script/upgrade.py" "$@"
Äã¿´¿´upgrade.pyµÄÄÚÈݾÍÖªµÀÁË
´«¸ø upgrade µÄÃüÁîÐвÎÊý
°Ñ"$@"¸ø "$cur_path/script/upgrade.py" ´¦Àí¡£
......