Technical Site
Spiritual Site
Heart Beat Powered by ASP.net

True/Flase in Classic VB

In classic VB (and classic ASP as well), zero is considered as false and any other non-zero integer is considered as true. 

While debugging an asp page, I come across following line: 

If Not Request.Form.Count Then 
... 

Now form count was 2 (true) so the condition should evaluate as false (Not true). But this was always evaluating as true. It took me half an hour to find the catch. 

What actually happening here was that Not is a bit-wise operator in VB. It flips the bits. So, 

2 is 0000 0010 in binary. 
NOT 2 is 1111 1101 in binary. 

Considering that the last bit is sign bit, this becomes -3. 

Now our condition If NOT (2) becomes If (-3), which always evaluates to true (non-zero integers are always true in VB). 


比如女性在生长发育的期间,就可能遇到很多形形色色的朋友粉嫩公主丰胸,有好的,也有不好的。女性这个时候要学会辨别。比如有些小年轻很早就出入社会丰胸方法,有些可能染上一身都戒不掉毒瘾等都有可能,轻的可能有抽烟喝酒的习惯丰胸酒酿蛋。这些对女性还稚嫩的身体来说来的太早,太快了。有可能太过承重了,女性身体就不能承受之重丰胸产品。
Bookmark
del.icio.us digg Spurl.net Wists Simpy Newsvine BlinkList Furl reddit FARK BlogMarks Yahoo! My Web smarking Ma.gnolia Segnalo
Share