O’Reilly Mastering Perl 2007 phần 9

ác chuỗi định dạng NCA có một bức thư cho mỗi phần còn lại của các đối số và nói với gói làm thế nào để giải thích nó. N xử lý đối số của nó như là một unsigned mạng để dài. C xử lý đối số của nó như là một char unsigned, và A xử lý đối số của nó như một ký tự ASCII. | Unary NOT The unary NOT operator sometimes called the complement operator returns the bitwise negation or l s complement of the value based on integer size of the architecture. This meansit doesn t care what the sign of the numeric value is it just flips all the bits my value i obnil llll my Icouplesest i value . printf Complement of n t b nis n t b n value complement I see that even th oughl gavet tan bitvalue it comes back as a 32-bit value because my MacBook hat slut mtegere Complement of is 11011111 llllblllllllllbllllllliooiuoooiv That s not verynkioutput. I d like the values to line up properly. To do that I need the integer size. That s easy enough to get from the Perl configuration though see Chapter 11 . Theigtegertiztiiinbytes soimultiply by eight the value I get from Perl s configuration itl usreiOn ieog it use Confl lf my int_size Config int size 8 print Int sizeis int_size n my value obnil _1eg 1 my complement value printf ComplementofXnWe i nt_size b nis n t int_size b n value complement Now my values Irne up property ahhough I d like It even more if I could see the leading zeros. You canfigure thstoneoutonyourown Int size ÌS32 ComP il lmllii is 11111111111111111111111100000000 I also have to betarefulhow I use the result I get from a unary NOT. Depending on ei value in negae e e . when tptmt neotbtdwith tuitUf I see that I flipped all the bits and that the nigitive ue lb - greater in magnsvudo than thi positive one. Thas t b s e I t 0 t 8 This is one bld e few plioe i io Perl iohire So V diilpmg ob-chne lnn bhows Sds This depeiVs i thi integer size ofyour J ocessoi. 254 I Chapter ill WoiliogwilhBsSa two s complement thinking and I won t go into that here. However when I print the number with a plain ol print Perl treats it as an unsigned value so that bit flipping doesn t do anything to the sign for the numbers that started positive and it makes negafltiL h O1 SLSim Sltme usr bin perl foreacymy XvsXua 65ti 1S8 5 65534 my .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
13    106    1    03-06-2024
2    1    1    03-06-2024
35    74    1    03-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.