Главная страница


ru.perl

 
 - RU.PERL ----------------------------------------------------------------------
 From : Ivan Frolkov                         2:5020/175.2   27 Nov 2004  19:13:57
 To : Uncle Sasha
 Subject : Re^5: заpаботок
 -------------------------------------------------------------------------------- 
 
 Sat Nov 27 2004 12:06, Nikolay Pichtin wrote to Artem Chuprina:
 
  NP> Про побитовые логические операции с нечислами и хотелось бы подробнее.
 
 В качестве рекламной акции привожу бесплатно кусок perldoc perlop
 
   Bitwise String Operators
 
     Bitstrings of any size may be manipulated by the bitwise operators ("~ |
     & ^").
 
     If the operands to a binary bitwise op are strings of different sizes, |
     and ^ ops act as though the shorter operand had additional zero bits on
     the right, while the & op acts as though the longer operand were
     truncated to the length of the shorter. The granularity for such
     extension or truncation is one or more bytes.
 
         # ASCII-based examples
         print "j p \n" ^ " a h";            # prints "JAPH\n"
         print "JA" | "  ph\n";              # prints "japh\n"
         print "japh\nJunk" & '_____';       # prints "JAPH\n";
         print 'p N$' ^ " E<H\n";            # prints "Perl\n";
 
     If you are intending to manipulate bitstrings, be certain that you're
     supplying bitstrings: If an operand is a number, that will imply a
     numeric bitwise operation. You may explicitly show which type of
     operation you intend by using """" or "0+", as in the examples below.
 
         $foo =  150  |  105 ;       # yields 255  (0x96 | 0x69 is 0xFF)
         $foo = '150' |  105 ;       # yields 255
         $foo =  150  | '105';       # yields 255
         $foo = '150' | '105';       # yields string '155' (under ASCII)
 
         $baz = 0+$foo & 0+$bar;     # both ops explicitly numeric
         $biz = "$foo" ^ "$bar";     # both ops explicitly stringy
 
     See the vec entry in the perlfunc manpage for information on how to
     manipulate individual bits in a bit vector.
 
 --- ifmail v.2.15dev5
  * Origin: FidoNet Online - http://www.fido-online.com (2:5020/175.2)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Пояснения   Nikolay Pichtin   25 Nov 2004 09:11:58 
 Re: Пояснения   Artem Chuprina   25 Nov 2004 18:39:53 
 Re: Пояснения   Nikolay Pichtin   27 Nov 2004 14:06:35 
 Re^5: заpаботок   Ivan Frolkov   27 Nov 2004 19:13:57 
 Re^5: заpаботок   Ivan Frolkov   27 Nov 2004 19:15:45 
 Re: Пояснения   Alexey Mahotkin   28 Nov 2004 01:38:44 
Архивное /ru.perl/33006a266d71.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional