{
    "mode": "perldoc",
    "parameter": "Bit::Vector::Overload",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Bit%3A%3AVector%3A%3AOverload/json",
    "generated": "2026-06-11T00:41:07Z",
    "synopsis": "Configuration\n$config = Bit::Vector->Configuration();\nBit::Vector->Configuration($config);\n$oldconfig = Bit::Vector->Configuration($newconfig);\nString Conversion\n$string = \"$vector\";             #  depending on configuration\nprint \"\\$vector = '$vector'\\n\";\nEmptyness\nif ($vector)  #  if not empty (non-zero)\nif (! $vector)  #  if empty (zero)\nunless ($vector)  #  if empty (zero)\nComplement (one's complement)\n$vector2 = ~$vector1;\n$vector = ~$vector;\nNegation (two's complement)\n$vector2 = -$vector1;\n$vector = -$vector;\nNorm\n$norm = abs($vector);  #  depending on configuration\nAbsolute\n$vector2 = abs($vector1);  #  depending on configuration\nConcatenation\n$vector3 = $vector1 . $vector2;\n$vector1 .= $vector2;\n$vector1 = $vector2 . $vector1;\n$vector2 = $vector1 . $scalar;  #  depending on configuration\n$vector2 = $scalar . $vector1;\n$vector .= $scalar;\nDuplication\n$vector2 = $vector1 x $factor;\n$vector x= $factor;\nShift Left\n$vector2 = $vector1 << $bits;\n$vector <<= $bits;\nShift Right\n$vector2 = $vector1 >> $bits;\n$vector >>= $bits;\nUnion\n$vector3 = $vector1 | $vector2;\n$vector1 |= $vector2;\n$vector2 = $vector1 | $scalar;\n$vector |= $scalar;\n$vector3 = $vector1 + $vector2;  #  depending on configuration\n$vector1 += $vector2;\n$vector2 = $vector1 + $scalar;\n$vector += $scalar;\nIntersection\n$vector3 = $vector1 & $vector2;\n$vector1 &= $vector2;\n$vector2 = $vector1 & $scalar;\n$vector &= $scalar;\n$vector3 = $vector1 * $vector2;  #  depending on configuration\n$vector1 *= $vector2;\n$vector2 = $vector1 * $scalar;\n$vector *= $scalar;\nExclusiveOr\n$vector3 = $vector1 ^ $vector2;\n$vector1 ^= $vector2;\n$vector2 = $vector1 ^ $scalar;\n$vector ^= $scalar;\nSet Difference\n$vector3 = $vector1 - $vector2;  #  depending on configuration\n$vector1 -= $vector2;\n$vector1 = $vector2 - $vector1;\n$vector2 = $vector1 - $scalar;\n$vector2 = $scalar - $vector1;\n$vector -= $scalar;\nAddition\n$vector3 = $vector1 + $vector2;  #  depending on configuration\n$vector1 += $vector2;\n$vector2 = $vector1 + $scalar;\n$vector += $scalar;\nSubtraction\n$vector3 = $vector1 - $vector2;  #  depending on configuration\n$vector1 -= $vector2;\n$vector1 = $vector2 - $vector1;\n$vector2 = $vector1 - $scalar;\n$vector2 = $scalar - $vector1;\n$vector -= $scalar;\nMultiplication\n$vector3 = $vector1 * $vector2;  #  depending on configuration\n$vector1 *= $vector2;\n$vector2 = $vector1 * $scalar;\n$vector *= $scalar;\nDivision\n$vector3 = $vector1 / $vector2;\n$vector1 /= $vector2;\n$vector1 = $vector2 / $vector1;\n$vector2 = $vector1 / $scalar;\n$vector2 = $scalar / $vector1;\n$vector /= $scalar;\nModulo\n$vector3 = $vector1 % $vector2;\n$vector1 %= $vector2;\n$vector1 = $vector2 % $vector1;\n$vector2 = $vector1 % $scalar;\n$vector2 = $scalar % $vector1;\n$vector %= $scalar;\nExponentiation\n$vector3 = $vector1  $vector2;\n$vector1 = $vector2;\n$vector2 = $vector1  $scalar;\n$vector2 = $scalar  $vector1;\n$vector = $scalar;\nIncrement\n++$vector;\n$vector++;\nDecrement\n--$vector;\n$vector--;\nLexical Comparison (unsigned)\n$cmp = $vector1 cmp $vector2;\nif ($vector1 lt $vector2)\nif ($vector1 le $vector2)\nif ($vector1 gt $vector2)\nif ($vector1 ge $vector2)\n$cmp = $vector cmp $scalar;\nif ($vector lt $scalar)\nif ($vector le $scalar)\nif ($vector gt $scalar)\nif ($vector ge $scalar)\nComparison (signed)\n$cmp = $vector1 <=> $vector2;\nif ($vector1 < $vector2)  #  depending on configuration\nif ($vector1 <= $vector2)\nif ($vector1 > $vector2)\nif ($vector1 >= $vector2)\n$cmp = $vector <=> $scalar;\nif ($vector < $scalar)  #  depending on configuration\nif ($vector <= $scalar)\nif ($vector > $scalar)\nif ($vector >= $scalar)\nEquality\nif ($vector1 eq $vector2)\nif ($vector1 ne $vector2)\nif ($vector eq $scalar)\nif ($vector ne $scalar)\nif ($vector1 == $vector2)\nif ($vector1 != $vector2)\nif ($vector == $scalar)\nif ($vector != $scalar)\nSubset Relationship\nif ($vector1 <= $vector2)  #  depending on configuration\nTrue Subset Relationship\nif ($vector1 < $vector2)  #  depending on configuration\nSuperset Relationship\nif ($vector1 >= $vector2)  #  depending on configuration\nTrue Superset Relationship\nif ($vector1 > $vector2)  #  depending on configuration",
    "sections": {
        "NAME": {
            "content": "Bit::Vector::Overload - Overloaded operators add-on for Bit::Vector\n",
            "subsections": []
        },
        "USAGE": {
            "content": "Note that you do not need to \"\"use Bit::Vector;\"\" in addition to this module.\n\nSimply \"\"use Bit::Vector::Overload;\"\" INSTEAD of \"\"use Bit::Vector;\"\". You can still use all the\nmethods from the \"Bit::Vector\" module in addition to the overloaded operators and methods\nprovided here after that.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Configuration\n$config = Bit::Vector->Configuration();\nBit::Vector->Configuration($config);\n$oldconfig = Bit::Vector->Configuration($newconfig);\n\nString Conversion\n$string = \"$vector\";             #  depending on configuration\nprint \"\\$vector = '$vector'\\n\";\n\nEmptyness\nif ($vector)  #  if not empty (non-zero)\nif (! $vector)  #  if empty (zero)\nunless ($vector)  #  if empty (zero)\n\nComplement (one's complement)\n$vector2 = ~$vector1;\n$vector = ~$vector;\n\nNegation (two's complement)\n$vector2 = -$vector1;\n$vector = -$vector;\n\nNorm\n$norm = abs($vector);  #  depending on configuration\n\nAbsolute\n$vector2 = abs($vector1);  #  depending on configuration\n\nConcatenation\n$vector3 = $vector1 . $vector2;\n$vector1 .= $vector2;\n$vector1 = $vector2 . $vector1;\n$vector2 = $vector1 . $scalar;  #  depending on configuration\n$vector2 = $scalar . $vector1;\n$vector .= $scalar;\n\nDuplication\n$vector2 = $vector1 x $factor;\n$vector x= $factor;\n\nShift Left\n$vector2 = $vector1 << $bits;\n$vector <<= $bits;\n\nShift Right\n$vector2 = $vector1 >> $bits;\n$vector >>= $bits;\n\nUnion\n$vector3 = $vector1 | $vector2;\n$vector1 |= $vector2;\n$vector2 = $vector1 | $scalar;\n$vector |= $scalar;\n\n$vector3 = $vector1 + $vector2;  #  depending on configuration\n$vector1 += $vector2;\n$vector2 = $vector1 + $scalar;\n$vector += $scalar;\n\nIntersection\n$vector3 = $vector1 & $vector2;\n$vector1 &= $vector2;\n$vector2 = $vector1 & $scalar;\n$vector &= $scalar;\n\n$vector3 = $vector1 * $vector2;  #  depending on configuration\n$vector1 *= $vector2;\n$vector2 = $vector1 * $scalar;\n$vector *= $scalar;\n\nExclusiveOr\n$vector3 = $vector1 ^ $vector2;\n$vector1 ^= $vector2;\n$vector2 = $vector1 ^ $scalar;\n$vector ^= $scalar;\n\nSet Difference\n$vector3 = $vector1 - $vector2;  #  depending on configuration\n$vector1 -= $vector2;\n$vector1 = $vector2 - $vector1;\n$vector2 = $vector1 - $scalar;\n$vector2 = $scalar - $vector1;\n$vector -= $scalar;\n\nAddition\n$vector3 = $vector1 + $vector2;  #  depending on configuration\n$vector1 += $vector2;\n$vector2 = $vector1 + $scalar;\n$vector += $scalar;\n\nSubtraction\n$vector3 = $vector1 - $vector2;  #  depending on configuration\n$vector1 -= $vector2;\n$vector1 = $vector2 - $vector1;\n$vector2 = $vector1 - $scalar;\n$vector2 = $scalar - $vector1;\n$vector -= $scalar;\n\nMultiplication\n$vector3 = $vector1 * $vector2;  #  depending on configuration\n$vector1 *= $vector2;\n$vector2 = $vector1 * $scalar;\n$vector *= $scalar;\n\nDivision\n$vector3 = $vector1 / $vector2;\n$vector1 /= $vector2;\n$vector1 = $vector2 / $vector1;\n$vector2 = $vector1 / $scalar;\n$vector2 = $scalar / $vector1;\n$vector /= $scalar;\n\nModulo\n$vector3 = $vector1 % $vector2;\n$vector1 %= $vector2;\n$vector1 = $vector2 % $vector1;\n$vector2 = $vector1 % $scalar;\n$vector2 = $scalar % $vector1;\n$vector %= $scalar;\n\nExponentiation\n$vector3 = $vector1  $vector2;\n$vector1 = $vector2;\n$vector2 = $vector1  $scalar;\n$vector2 = $scalar  $vector1;\n$vector = $scalar;\n\nIncrement\n++$vector;\n$vector++;\n\nDecrement\n--$vector;\n$vector--;\n\nLexical Comparison (unsigned)\n$cmp = $vector1 cmp $vector2;\nif ($vector1 lt $vector2)\nif ($vector1 le $vector2)\nif ($vector1 gt $vector2)\nif ($vector1 ge $vector2)\n\n$cmp = $vector cmp $scalar;\nif ($vector lt $scalar)\nif ($vector le $scalar)\nif ($vector gt $scalar)\nif ($vector ge $scalar)\n\nComparison (signed)\n$cmp = $vector1 <=> $vector2;\nif ($vector1 < $vector2)  #  depending on configuration\nif ($vector1 <= $vector2)\nif ($vector1 > $vector2)\nif ($vector1 >= $vector2)\n\n$cmp = $vector <=> $scalar;\nif ($vector < $scalar)  #  depending on configuration\nif ($vector <= $scalar)\nif ($vector > $scalar)\nif ($vector >= $scalar)\n\nEquality\nif ($vector1 eq $vector2)\nif ($vector1 ne $vector2)\nif ($vector eq $scalar)\nif ($vector ne $scalar)\n\nif ($vector1 == $vector2)\nif ($vector1 != $vector2)\nif ($vector == $scalar)\nif ($vector != $scalar)\n\nSubset Relationship\nif ($vector1 <= $vector2)  #  depending on configuration\n\nTrue Subset Relationship\nif ($vector1 < $vector2)  #  depending on configuration\n\nSuperset Relationship\nif ($vector1 >= $vector2)  #  depending on configuration\n\nTrue Superset Relationship\nif ($vector1 > $vector2)  #  depending on configuration\n",
            "subsections": []
        },
        "IMPORTANT NOTES": {
            "content": "* Boolean values\n\nBoolean values in this module are always a numeric zero (\"0\") for \"false\" and a numeric one\n(\"1\") for \"true\".\n\n* Negative numbers\n\nNumeric factors (as needed for the \"\"<<\"\", \"\">>\"\" and \"\"x\"\" operators) and bit numbers are\nalways regarded as being UNSIGNED.\n\nAs a consequence, whenever you pass a negative number for such a factor or bit number, it will\nbe treated as a (usually very large) positive number due to its internal two's complement\nbinary representation, usually resulting in malfunctions or an \"index out of range\" error\nmessage and program abortion.\n\nNote that this does not apply to \"big integer\" decimal numbers, which are (usually) passed as\nstrings, and which may of course be negative (see also the section \"Big integers\" a little\nfurther below).\n\n* Overloaded operators configuration\n\nNote that the behaviour of certain overloaded operators can be changed in various ways by\nmeans of the \"\"Configuration()\"\" method (for more details, see the description of this method\nfurther below).\n\nFor instance, scalars (i.e., numbers and strings) provided as operands to overloaded operators\nare automatically converted to bit vectors, internally.\n\nThese scalars are thereby automatically assumed to be indices or to be in hexadecimal, binary,\ndecimal or enumeration format, depending on the configuration.\n\nSimilarly, when converting bit vectors to strings using double quotes (\"\"), the output format\nwill also depend on the previously chosen configuration.\n\nFinally, some overloaded operators may have different semantics depending on the proper\nconfiguration; for instance, the operator \"+\" can be the \"union\" operator from set theory or\nthe arithmetic \"add\" operator.\n\nIn all cases (input, output and operator semantics), the defaults have been chosen in such a\nway so that the behaviour of the module is backward compatible with previous versions.\n\n* \"Big integers\"\n\nAs long as \"big integers\" (for \"big integer\" arithmetic) are small enough so that Perl doesn't\nneed scientific notation (exponents) to be able to represent them internally, you can provide\nthese \"big integer\" constants to the overloaded operators of this module (or to the method\n\"\"fromDec()\"\") in numeric form (i.e., either as a numeric constant or expression or as a Perl\nvariable containing a numeric value).\n\nNote that you will get an error message (resulting in program abortion) if your \"big integer\"\nnumbers exceed that limit.\n\nBecause this limit is machine-dependent and not obvious to find out, it is strongly\nrecommended that you enclose ALL your \"big integer\" constants in your programs in (double or\nsingle) quotes.\n\nExamples:\n\n$vector /= 10;  #  ok because number is small\n\n$vector /= -10;  #  ok for same reason\n\n$vector /= \"10\";  #  always correct\n\n$vector += \"1152921504606846976\";  #  quotes probably required here\n\nAll examples assume\n\nBit::Vector->Configuration(\"input=decimal\");\n\nhaving been set beforehand.\n\nNote also that this module does not support scientific notation (exponents) for \"big integer\"\ndecimal numbers because you can always make the bit vector large enough for the whole number\nto fit without loss of precision (as it would occur if scientific notation were used).\n\nFinally, note that the only characters allowed in \"big integer\" constant strings are the\ndigits 0..9 and an optional leading sign (\"\"+\"\" or \"\"-\"\").\n\nAll other characters produce a syntax error.\n\n* Valid operands for overloaded operators\n\nAll overloaded operators expect at least one bit vector operand, in order for the operator to\n\"know\" that not the usual operation is to be carried out, but rather the overloaded variant.\n\nThis is especially true for all unary operators:\n\n\"$vector\"\nif ($vector)\nif (!$vector)\n~$vector\n-$vector\nabs($vector)\n++$vector\n$vector++\n--$vector\n$vector--\n\nFor obvious reasons the left operand (the \"lvalue\") of all assignment operators is also\nrequired to be a bit vector:\n\n.=\nx=\n<<=\n>>=\n|=\n&=\n^=\n+=\n-=\n*=\n/=\n%=\n=\n\nIn the case of three special operators, namely \"\"<<\"\", \"\">>\"\" and \"\"x\"\", as well as their\nrelated assignment variants, \"\"<<=\"\", \"\">>=\"\" and \"\"x=\"\", the left operand is ALWAYS a bit\nvector and the right operand is ALWAYS a number (which is the factor indicating how many times\nthe operator is to be applied).\n\nIn all truly binary operators, i.e.,\n\n.\n|\n&\n^\n+\n-\n*\n/\n%\n\n<=>   cmp\n==    eq\n!=    ne\n<     lt\n<=    le\n>     gt\n>=    ge\n\none of either operands may be replaced by a Perl scalar, i.e., a number or a string, either as\na Perl constant, a Perl expression or a Perl variable yielding a number or a string.\n\nThe same applies to the right side operand (the \"rvalue\") of the remaining assignment\noperators, i.e.,\n\n.=\n|=\n&=\n^=\n+=\n-=\n*=\n/=\n%=\n=\n\nNote that this Perl scalar should be of the correct type, i.e., numeric or string, for the\nchosen configuration, because otherwise a warning message will occur if your program runs\nunder the \"\"-w\"\" switch of Perl.\n\nThe acceptable scalar types for each possible configuration are the following:\n\ninput = bit indices    (default)  :    numeric\ninput = hexadecimal               :    string\ninput = binary                    :    string\ninput = decimal                   :    string     (in general)\ninput = decimal                   :    numeric    (if small enough)\ninput = enumeration               :    string\n\nNOTE ALSO THAT THESE SCALAR OPERANDS ARE CONVERTED TO BIT VECTORS OF THE SAME SIZE AS THE BIT\nVECTOR WHICH IS THE OTHER OPERAND.\n\nThe only exception from this rule is the concatenation operator (\"\".\"\") and its assignment\nvariant (\"\".=\"\"):\n\nIf one of the two operands of the concatenation operator (\"\".\"\") is not a bit vector object\nbut a Perl scalar, the contents of the remaining bit vector operand are converted into a\nstring (the format of which depends on the configuration set with the \"\"Configuration()\"\"\nmethod), which is then concatenated in the proper order (i.e., as indicated by the order of\nthe two operands) with the Perl scalar (in other words, a string is returned in such a case\ninstead of a bit vector object!).\n\nIf the right side operand (the \"rvalue\") of the assignment variant (\"\".=\"\") of the\nconcatenation operator is a Perl scalar, it is converted internally to a bit vector of the\nsame size as the left side operand provided that the configuration states that scalars are to\nbe regarded as indices, decimal strings or enumerations.\n\nIf the configuration states that scalars are to be regarded as hexadecimal or boolean strings,\nhowever, these strings are converted to bit vectors of a size matching the length of the input\nstring, i.e., four times the length for hexadecimal strings (because each hexadecimal digit is\nworth 4 bits) and once the length for binary strings.\n\nIf a decimal number (\"big integer\") is too large to be stored in a bit vector of the given\nsize, a \"numeric overflow error\" occurs.\n\nIf a bit index is out of range for the given bit vector, an \"index out of range\" error occurs.\n\nIf a scalar operand cannot be converted successfully due to invalid syntax, a fatal \"input\nstring syntax error\" is issued.\n\nIf the two operands of the operator \"\"<<\"\", \"\">>\"\" or \"\"x\"\" are reversed, a fatal \"reversed\noperands error\" occurs.\n\nIf an operand is neither a bit vector nor a scalar, then a fatal \"illegal operand type error\"\noccurs.\n\n* Bit order\n\nNote that bit vectors are stored least order bit and least order word first internally.\n\nI.e., bit #0 of any given bit vector corresponds to bit #0 of word #0 in the array of machine\nwords representing the bit vector.\n\n(Where word #0 comes first in memory, i.e., it is stored at the least memory address in the\nallocated block of memory holding the given bit vector.)\n\nNote however that machine words can be stored least order byte first or last, depending on\nyour system's implementation.\n\nNote further that whenever bit vectors are converted to and from (binary or hexadecimal)\nstrings, the RIGHTMOST bit is always the LEAST SIGNIFICANT one, and the LEFTMOST bit is always\nthe MOST SIGNIFICANT bit.\n\nThis is because in our western culture, numbers are always represented in this way (least\nsignificant to most significant digits go from right to left).\n\nOf course this requires an internal reversion of order, which the corresponding conversion\nmethods perform automatically (without any additional overhead, it's just a matter of starting\nthe internal loop at the bottom or the top end).\n\n* Matching sizes\n\nIn general, for methods involving several bit vectors at the same time, all bit vector\narguments must have identical sizes (number of bits), or a fatal \"size mismatch\" error will\noccur.\n\nExceptions from this rule are the methods \"\"Concat()\"\", \"\"ConcatList()\"\", \"\"Copy()\"\",\n\"\"IntervalCopy()\"\" and \"\"IntervalSubstitute()\"\", where no conditions at all are imposed on\nthe size of their bit vector arguments.\n\nIn method \"\"Multiply()\"\", all three bit vector arguments must in principle obey the rule of\nmatching sizes, but the bit vector in which the result of the multiplication is to be stored\nmay be larger than the two bit vector arguments containing the factors for the multiplication.\n\nIn method \"\"Power()\"\", the bit vector for the result must be the same size or greater than the\nbase of the exponentiation term. The exponent can be any size.\n\nThe same applies to the corresponding overloaded operators.\n\n* Index ranges\n\nAll indices for any given bits must lie between \"0\" and \"\"$vector->Size()-1\"\", or a fatal\n\"index out of range\" error will occur.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "* \"$config = Bit::Vector->Configuration();\"\n\n* \"Bit::Vector->Configuration($config);\"\n\n* \"$oldconfig = Bit::Vector->Configuration($newconfig);\"\n\nThis method serves to alter the semantics (i.e., behaviour) of certain overloaded operators\n(which are all implemented in Perl, by the way).\n\nIt does not have any effect whatsoever on anything else. In particular, it does not affect the\nmethods implemented in C.\n\nThe method accepts an (optional) string as input in which certain keywords are expected, which\ninfluence some or almost all of the overloaded operators in several possible ways.\n\nThe method always returns a string (which you do not need to take care of, i.e., to store, in\ncase you aren't interested in keeping it) which is a complete representation of the current\nconfiguration (i.e., BEFORE any modifications are applied) and which can be fed back to this\nmethod later in order to restore the previous configuration.\n\nThere are three aspects of the way certain overloaded operators behave which can be controlled\nwith this method:\n\n+  the way scalar operands (replacing one of the two\nbit vector object operands) are automatically\nconverted internally into a bit vector object of\ntheir own,\n\n+  the operation certain overloaded operators perform,\ni.e., an operation with sets or an arithmetic\noperation,\n\n+  the format to which bit vectors are converted\nautomatically when they are enclosed in double\nquotes.\n\nThe input string may contain any number of assignments, each of which controls one of these\nthree aspects.\n\nEach assignment has the form \"\"<which>=<value>\"\".\n\n\"\"<which>\"\" and \"\"<value>\"\" thereby consist of letters (\"[a-zA-Z]\") and white space.\n\nMultiple assignments have to be separated by one or more comma (\",\"), semi-colon (\";\"), colon\n(\":\"), vertical bar (\"|\"), slash (\"/\"), newline (\"\\n\"), ampersand (\"&\"), plus (\"+\") or dash\n(\"-\").\n\nEmpty lines or statements (only white space) are allowed but will be ignored.\n\n\"\"<which>\"\" has to contain one or more keywords from one of three groups, each group\nrepresenting one of the three aspects that the \"\"Configuration()\"\" method controls:\n\n+  \"^scalar\", \"^input\", \"^in$\"\n\n+  \"^operator\", \"^semantic\", \"^ops$\"\n\n+  \"^string\", \"^output\", \"^out$\"\n\nThe character \"^\" thereby denotes the beginning of a word, and \"$\" denotes the end. Case is\nignored (!).\n\nUsing these keywords, you can build any phrase you like to select one of the three aspects\n(see also examples given below).\n\nThe only condition is that no other keyword from any of the other two groups may match -\notherwise a syntax error will occur (i.e., ambiguities are forbidden). A syntax error also\noccurs if none of the keywords matches.\n\nThis same principle applies to \"\"<value>\"\":\n\nDepending on which aspect you specified for \"\"<which>\"\", there are different groups of\nkeywords that determine the value the selected aspect will be set to:\n\n+  \"<which>\" = \"^scalar\", \"^input\", \"^in$\":\n\n\"<value>\" =\n\n*  \"^bit$\", \"^index\", \"^indice\"\n*  \"^hex\"\n*  \"^bin\"\n*  \"^dec\"\n*  \"^enum\"\n\n+  \"<which>\" = \"^operator\", \"^semantic\", \"^ops$\":\n\n\"<value>\" =\n\n*  \"^set$\"\n*  \"^arithmetic\"\n\n+  \"<which>\" = \"^string\", \"^output\", \"^out$\":\n\n\"<value>\" =\n\n*  \"^hex\"\n*  \"^bin\"\n*  \"^dec\"\n*  \"^enum\"\n\nExamples:\n\n\"Any scalar input I provide should be considered to be = a bit index\"\n\n\"I want to have operator semantics suitable for = arithmetics\"\n\n\"Any bit vector in double quotes is to be output as = an enumeration\"\n\nSCALAR INPUT:\n\nIn the case of scalar input, \"\"^bit$\"\", \"\"^index\"\", or \"\"^indice\"\" all cause scalar input to\nbe considered to represent a bit index, i.e., \"\"$vector ^= 5;\"\" will flip bit #5 in the given\nbit vector (this is essentially the same as \"\"$vector->bitflip(5);\"\").\n\nNote that \"bit indices\" is the default setting for \"scalar input\".\n\nThe keyword \"\"^hex\"\" will cause scalar input to be considered as being in hexadecimal, i.e.,\n\"\"$vector ^= 5;\"\" will flip bit #0 and bit #2 (because hexadecimal \"5\" is binary \"0101\").\n\n(Note though that hexadecimal input should always be enclosed in quotes, otherwise it will be\ninterpreted as a decimal number by Perl! The example relies on the fact that hexadecimal \"0-9\"\nand decimal \"0-9\" are the same.)\n\nThe keyword \"\"^bin\"\" will cause scalar input to be considered as being in binary format. All\ncharacters except \"0\" and \"1\" are forbidden in this case (i.e., produce a syntax error).\n\n\"\"$vector ^= '0101';\"\", for instance, will flip bit #0 and bit #2.\n\nThe keyword \"\"^dec\"\" causes scalar input to be considered as integers in decimal format, i.e.,\n\"\"$vector ^= 5;\"\" will flip bit #0 and bit #2 (because decimal \"5\" is binary \"0101\").\n\n(Note though that all decimal input should be enclosed in quotes, because for large numbers,\nPerl will use scientific notation internally for representing them, which produces a syntax\nerror because scientific notation is neither supported by this module nor needed.)\n\nFinally, the keyword \"\"^enum\"\" causes scalar input to be considered as being a list\n(\"enumeration\") of indices and ranges of (contiguous) indices, i.e., \"\"$vector |=\n'2,3,5,7-13,17-23';\"\" will cause bits #2, #3, #5, #7 through #13 and #17 through #23 to be\nset.\n\nOPERATOR SEMANTICS:\n\nSeveral overloaded operators can have two distinct functions depending on this setting.\n\nThe affected operators are: \"\"+\"\", \"\"-\"\", \"\"*\"\", \"\"<\"\", \"\"<=\"\", \"\">\"\" and \"\">=\"\".\n\nWith the default setting, \"set operations\", these operators perform:\n\n+       set union                           ( set1  u   set2 )\n-       set difference                      ( set1  \\   set2 )\n*       set intersection                    ( set1  n   set2 )\n<       true subset relationship            ( set1  <   set2 )\n<=      subset relationship                 ( set1  <=  set2 )\n>       true superset relationship          ( set1  >   set2 )\n>=      superset relationship               ( set1  >=  set2 )\n\nWith the alternative setting, \"arithmetic operations\", these operators perform:\n\n+       addition                            ( num1  +   num2 )\n-       subtraction                         ( num1  -   num2 )\n*       multiplication                      ( num1  *   num2 )\n<       \"less than\" comparison              ( num1  <   num2 )\n<=      \"less than or equal\" comparison     ( num1  <=  num2 )\n>       \"greater than\" comparison           ( num1  >   num2 )\n>=      \"greater than or equal\" comparison  ( num1  >=  num2 )\n\nNote that these latter comparison operators (\"\"<\"\", \"\"<=\"\", \"\">\"\" and \"\">=\"\") regard their\noperands as being SIGNED.\n\nTo perform comparisons with UNSIGNED operands, use the operators \"\"lt\"\", \"\"le\"\", \"\"gt\"\" and\n\"\"ge\"\" instead (in contrast to the operators above, these operators are NOT affected by the\n\"operator semantics\" setting).\n\nSTRING OUTPUT:\n\nThere are four methods which convert the contents of a given bit vector into a string:\n\"\"toHex()\"\", \"\"toBin()\"\", \"\"toDec()\"\" and \"\"toEnum()\"\" (not counting \"\"BlockRead()\"\",\nsince this method does not return a human-readable string).\n\n(For conversion to octal, see the description of the method \"\"ChunkListRead()\"\".)\n\nTherefore, there are four possible formats into which a bit vector can be converted when it is\nenclosed in double quotes, for example:\n\nprint \"\\$vector = '$vector'\\n\";\n$string = \"$vector\";\n\nHence you can set \"string output\" to four different values: To \"hex\" for hexadecimal format\n(which is the default), to \"bin\" for binary format, to \"dec\" for conversion to decimal numbers\nand to \"enum\" for conversion to enumerations (\".newsrc\" style sets).\n\nBEWARE that the conversion to decimal numbers is inherently slow; it can easily take up\nseveral seconds for a single large bit vector!\n\nTherefore you should store the decimal strings returned to you rather than converting a given\nbit vector again.\n\nEXAMPLES:\n\nThe default setting as returned by the method \"\"Configuration()\"\" is:\n\nScalar Input       = Bit Index\nOperator Semantics = Set Operators\nString Output      = Hexadecimal\n\nPerforming a statement such as:\n\nBit::Vector->Configuration(\"in=bin,ops=arithmetic,out=bin\");\nprint Bit::Vector->Configuration(), \"\\n\";\n\nyields the following output:\n\nScalar Input       = Binary\nOperator Semantics = Arithmetic Operators\nString Output      = Binary\n\nNote that you can always feed this output back into the \"\"Configuration()\"\" method to restore\nthat setting later.\n\nThis also means that you can enter the same given setting with almost any degree of verbosity\nyou like (as long as the required keywords appear and no ambiguities arise).\n\nNote further that any aspect you do not specify is not changed, i.e., the statement\n\nBit::Vector->Configuration(\"operators = arithmetic\");\n\nleaves all other aspects unchanged.\n\n* \"$vector\"\n\nRemember that variables enclosed in double quotes are always interpolated in Perl.\n\nWhenever a Perl variable containing the reference of a \"Bit::Vector\" object is enclosed in\ndouble quotes (either alone or together with other text and/or variables), the contents of the\ncorresponding bit vector are converted into a printable string.\n\nSince there are several conversion methods available in this module (see the description of\nthe methods \"\"toHex()\"\", \"\"toBin()\"\", \"\"toDec()\"\" and \"\"toEnum()\"\"), it is of course\ndesirable to be able to choose which of these methods should be applied in this case.\n\nThis can actually be done by changing the configuration of this module using the method\n\"\"Configure()\"\" (see the previous chapter, immediately above).\n\nThe default is conversion to hexadecimal.\n\n* \"if ($vector)\"\n\nIt is possible to use a Perl variable containing the reference of a \"Bit::Vector\" object as a\nboolean expression.\n\nThe condition above is true if the corresponding bit vector contains at least one set bit, and\nit is false if ALL bits of the corresponding bit vector are cleared.\n\n* \"if (!$vector)\"\n\nSince it is possible to use a Perl variable containing the reference of a \"Bit::Vector\" object\nas a boolean expression, you can of course also negate this boolean expression.\n\nThe condition above is true if ALL bits of the corresponding bit vector are cleared, and it is\nfalse if the corresponding bit vector contains at least one set bit.\n\nNote that this is NOT the same as using the method \"\"isfull()\"\", which returns true if ALL\nbits of the corresponding bit vector are SET.\n\n* \"~$vector\"\n\nThis term returns a new bit vector object which is the one's complement of the given bit\nvector.\n\nThis is equivalent to inverting all bits.\n\n* \"-$vector\" (unary minus)\n\nThis term returns a new bit vector object which is the two's complement of the given bit\nvector.\n\nThis is equivalent to inverting all bits and incrementing the result by one.\n\n(This is the same as changing the sign of a number in two's complement binary representation.)\n\n* \"abs($vector)\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns the number of set bits in the given bit vector (this is the\nsame as calculating the number of elements which are contained in the given set) - which is\nthe default behaviour, or it returns a new bit vector object which contains the absolute value\nof the number stored in the given bit vector.\n\n* \"$vector1 . $vector2\"\n\nThis term usually returns a new bit vector object which is the result of the concatenation of\nthe two bit vector operands.\n\nThe left operand becomes the most significant, and the right operand becomes the least\nsignificant part of the new bit vector object.\n\nIf one of the two operands is not a bit vector object but a Perl scalar, however, the contents\nof the remaining bit vector operand are converted into a string (the format of which depends\non the configuration set with the \"\"Configuration()\"\" method), which is then concatenated in\nthe proper order (i.e., as indicated by the order of the two operands) with the Perl scalar.\n\nIn other words, a string is returned in such a case instead of a bit vector object!\n\n* \"$vector x $factor\"\n\nThis term returns a new bit vector object which is the concatenation of as many copies of the\ngiven bit vector operand (the left operand) as the factor (the right operand) specifies.\n\nIf the factor is zero, a bit vector object with a length of zero bits is returned.\n\nIf the factor is one, just a new copy of the given bit vector is returned.\n\nNote that a fatal \"reversed operands error\" occurs if the two operands are swapped.\n\n* \"$vector << $bits\"\n\nThis term returns a new bit vector object which is a copy of the given bit vector (the left\noperand), which is then shifted left (towards the most significant bit) by as many places as\nthe right operand, \"$bits\", specifies.\n\nThis means that the \"$bits\" most significant bits are lost, all other bits move up by \"$bits\"\npositions, and the \"$bits\" least significant bits that have been left unoccupied by this shift\nare all set to zero.\n\nIf \"$bits\" is greater than the number of bits of the given bit vector, this term returns an\nempty bit vector (i.e., with all bits cleared) of the same size as the given bit vector.\n\nNote that a fatal \"reversed operands error\" occurs if the two operands are swapped.\n\n* \"$vector >> $bits\"\n\nThis term returns a new bit vector object which is a copy of the given bit vector (the left\noperand), which is then shifted right (towards the least significant bit) by as many places as\nthe right operand, \"$bits\", specifies.\n\nThis means that the \"$bits\" least significant bits are lost, all other bits move down by\n\"$bits\" positions, and the \"$bits\" most significant bits that have been left unoccupied by\nthis shift are all set to zero.\n\nIf \"$bits\" is greater than the number of bits of the given bit vector, this term returns an\nempty bit vector (i.e., with all bits cleared) of the same size as the given bit vector.\n\nNote that a fatal \"reversed operands error\" occurs if the two operands are swapped.\n\n* \"$vector1 | $vector2\"\n\nThis term returns a new bit vector object which is the result of a bitwise OR operation\nbetween the two bit vector operands.\n\nThis is the same as calculating the union of two sets.\n\n* \"$vector1 & $vector2\"\n\nThis term returns a new bit vector object which is the result of a bitwise AND operation\nbetween the two bit vector operands.\n\nThis is the same as calculating the intersection of two sets.\n\n* \"$vector1 ^ $vector2\"\n\nThis term returns a new bit vector object which is the result of a bitwise XOR (exclusive-or)\noperation between the two bit vector operands.\n\nThis is the same as calculating the symmetric difference of two sets.\n\n* \"$vector1 + $vector2\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns a new bit vector object which is the result of a bitwise OR\noperation between the two bit vector operands (this is the same as calculating the union of\ntwo sets) - which is the default behaviour, or it returns a new bit vector object which\ncontains the sum of the two numbers stored in the two bit vector operands.\n\n* \"$vector1 - $vector2\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns a new bit vector object which is the set difference of the\ntwo sets represented in the two bit vector operands - which is the default behaviour, or it\nreturns a new bit vector object which contains the difference of the two numbers stored in the\ntwo bit vector operands.\n\n* \"$vector1 * $vector2\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns a new bit vector object which is the result of a bitwise\nAND operation between the two bit vector operands (this is the same as calculating the\nintersection of two sets) - which is the default behaviour, or it returns a new bit vector\nobject which contains the product of the two numbers stored in the two bit vector operands.\n\n* \"$vector1 / $vector2\"\n\nThis term returns a new bit vector object containing the result of the division of the two\nnumbers stored in the two bit vector operands.\n\n* \"$vector1 % $vector2\"\n\nThis term returns a new bit vector object containing the remainder of the division of the two\nnumbers stored in the two bit vector operands.\n\n* \"$vector1  $vector2\"\n\nThis term returns a new bit vector object containing the result of the exponentiation of the\nleft bit vector elevated to the right bit vector's power.\n\n* \"$vector1 .= $vector2;\"\n\nThis statement \"appends\" the right bit vector operand (the \"rvalue\") to the left one (the\n\"lvalue\").\n\nThe former contents of the left operand become the most significant part of the resulting bit\nvector, and the right operand becomes the least significant part.\n\nSince bit vectors are stored in \"least order bit first\" order, this actually requires the left\noperand to be shifted \"up\" by the length of the right operand, which is then copied to the now\nfreed least significant part of the left operand.\n\nIf the right operand is a Perl scalar, it is first converted to a bit vector of the same size\nas the left operand, provided that the configuration states that scalars are to be regarded as\nindices, decimal strings or enumerations.\n\nIf the configuration states that scalars are to be regarded as hexadecimal or boolean strings,\nhowever, these strings are converted to bit vectors of a size matching the length of the input\nstring, i.e., four times the length for hexadecimal strings (because each hexadecimal digit is\nworth 4 bits) and once the length for binary strings.\n\n* \"$vector x= $factor;\"\n\nThis statement replaces the given bit vector by a concatenation of as many copies of the\noriginal contents of the given bit vector as the factor (the right operand) specifies.\n\nIf the factor is zero, the given bit vector is resized to a length of zero bits.\n\nIf the factor is one, the given bit vector is not changed at all.\n\n* \"$vector <<= $bits;\"\n\nThis statement moves the contents of the given bit vector left by \"$bits\" positions (towards\nthe most significant bit).\n\nThis means that the \"$bits\" most significant bits are lost, all other bits move up by \"$bits\"\npositions, and the \"$bits\" least significant bits that have been left unoccupied by this shift\nare all set to zero.\n\nIf \"$bits\" is greater than the number of bits of the given bit vector, the given bit vector is\nerased completely (i.e., all bits are cleared).\n\n* \"$vector >>= $bits;\"\n\nThis statement moves the contents of the given bit vector right by \"$bits\" positions (towards\nthe least significant bit).\n\nThis means that the \"$bits\" least significant bits are lost, all other bits move down by\n\"$bits\" positions, and the \"$bits\" most significant bits that have been left unoccupied by\nthis shift are all set to zero.\n\nIf \"$bits\" is greater than the number of bits of the given bit vector, the given bit vector is\nerased completely (i.e., all bits are cleared).\n\n* \"$vector1 |= $vector2;\"\n\nThis statement performs a bitwise OR operation between the two bit vector operands and stores\nthe result in the left operand.\n\nThis is the same as calculating the union of two sets.\n\n* \"$vector1 &= $vector2;\"\n\nThis statement performs a bitwise AND operation between the two bit vector operands and stores\nthe result in the left operand.\n\nThis is the same as calculating the intersection of two sets.\n\n* \"$vector1 ^= $vector2;\"\n\nThis statement performs a bitwise XOR (exclusive-or) operation between the two bit vector\noperands and stores the result in the left operand.\n\nThis is the same as calculating the symmetric difference of two sets.\n\n* \"$vector1 += $vector2;\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this statement either performs a bitwise OR operation between the two bit vector\noperands (this is the same as calculating the union of two sets) - which is the default\nbehaviour, or it calculates the sum of the two numbers stored in the two bit vector operands.\n\nThe result of this operation is stored in the left operand.\n\n* \"$vector1 -= $vector2;\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this statement either calculates the set difference of the two sets represented in\nthe two bit vector operands - which is the default behaviour, or it calculates the difference\nof the two numbers stored in the two bit vector operands.\n\nThe result of this operation is stored in the left operand.\n\n* \"$vector1 *= $vector2;\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this statement either performs a bitwise AND operation between the two bit vector\noperands (this is the same as calculating the intersection of two sets) - which is the default\nbehaviour, or it calculates the product of the two numbers stored in the two bit vector\noperands.\n\nThe result of this operation is stored in the left operand.\n\n* \"$vector1 /= $vector2;\"\n\nThis statement puts the result of the division of the two numbers stored in the two bit vector\noperands into the left operand.\n\n* \"$vector1 %= $vector2;\"\n\nThis statement puts the remainder of the division of the two numbers stored in the two bit\nvector operands into the left operand.\n\n* \"$vector1 = $vector2;\"\n\nThis statement puts the result of the exponentiation of the left operand elevated to the right\noperand's power into the left operand.\n\n* \"++$vector\", \"$vector++\"\n\nThis operator performs pre- and post-incrementation of the given bit vector.\n\nThe value returned by this term is a reference of the given bit vector object (after or before\nthe incrementation, respectively).\n\n* \"--$vector\", \"$vector--\"\n\nThis operator performs pre- and post-decrementation of the given bit vector.\n\nThe value returned by this term is a reference of the given bit vector object (after or before\nthe decrementation, respectively).\n\n* \"($vector1 cmp $vector2)\"\n\nThis term returns \"-1\" if \"$vector1\" is less than \"$vector2\", \"0\" if \"$vector1\" and \"$vector2\"\nare the same, and \"1\" if \"$vector1\" is greater than \"$vector2\".\n\nThis comparison assumes UNSIGNED bit vectors.\n\n* \"($vector1 eq $vector2)\"\n\nThis term returns true (\"1\") if the contents of the two bit vector operands are the same and\nfalse (\"0\") otherwise.\n\n* \"($vector1 ne $vector2)\"\n\nThis term returns true (\"1\") if the two bit vector operands differ and false (\"0\") otherwise.\n\n* \"($vector1 lt $vector2)\"\n\nThis term returns true (\"1\") if \"$vector1\" is less than \"$vector2\", and false (\"0\") otherwise.\n\nThis comparison assumes UNSIGNED bit vectors.\n\n* \"($vector1 le $vector2)\"\n\nThis term returns true (\"1\") if \"$vector1\" is less than or equal to \"$vector2\", and false\n(\"0\") otherwise.\n\nThis comparison assumes UNSIGNED bit vectors.\n\n* \"($vector1 gt $vector2)\"\n\nThis term returns true (\"1\") if \"$vector1\" is greater than \"$vector2\", and false (\"0\")\notherwise.\n\nThis comparison assumes UNSIGNED bit vectors.\n\n* \"($vector1 ge $vector2)\"\n\nThis term returns true (\"1\") if \"$vector1\" is greater than or equal to \"$vector2\", and false\n(\"0\") otherwise.\n\nThis comparison assumes UNSIGNED bit vectors.\n\n* \"($vector1 <=> $vector2)\"\n\nThis term returns \"-1\" if \"$vector1\" is less than \"$vector2\", \"0\" if \"$vector1\" and \"$vector2\"\nare the same, and \"1\" if \"$vector1\" is greater than \"$vector2\".\n\nThis comparison assumes SIGNED bit vectors.\n\n* \"($vector1 == $vector2)\"\n\nThis term returns true (\"1\") if the contents of the two bit vector operands are the same and\nfalse (\"0\") otherwise.\n\n* \"($vector1 != $vector2)\"\n\nThis term returns true (\"1\") if the two bit vector operands differ and false (\"0\") otherwise.\n\n* \"($vector1 < $vector2)\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns true (\"1\") if \"$vector1\" is a true subset of \"$vector2\"\n(and false (\"0\") otherwise) - which is the default behaviour, or it returns true (\"1\") if\n\"$vector1\" is less than \"$vector2\" (and false (\"0\") otherwise).\n\nThe latter comparison assumes SIGNED bit vectors.\n\n* \"($vector1 <= $vector2)\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns true (\"1\") if \"$vector1\" is a subset of \"$vector2\" (and\nfalse (\"0\") otherwise) - which is the default behaviour, or it returns true (\"1\") if\n\"$vector1\" is less than or equal to \"$vector2\" (and false (\"0\") otherwise).\n\nThe latter comparison assumes SIGNED bit vectors.\n\n* \"($vector1 > $vector2)\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns true (\"1\") if \"$vector1\" is a true superset of \"$vector2\"\n(and false (\"0\") otherwise) - which is the default behaviour, or it returns true (\"1\") if\n\"$vector1\" is greater than \"$vector2\" (and false (\"0\") otherwise).\n\nThe latter comparison assumes SIGNED bit vectors.\n\n* \"($vector1 >= $vector2)\"\n\nDepending on the configuration (see the description of the method \"\"Configuration()\"\" for more\ndetails), this term either returns true (\"1\") if \"$vector1\" is a superset of \"$vector2\" (and\nfalse (\"0\") otherwise) - which is the default behaviour, or it returns true (\"1\") if\n\"$vector1\" is greater than or equal to \"$vector2\" (and false (\"0\") otherwise).\n\nThe latter comparison assumes SIGNED bit vectors.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Bit::Vector(3), Bit::Vector::String(3).\n",
            "subsections": []
        },
        "VERSION": {
            "content": "This man page documents \"Bit::Vector::Overload\" version 7.4.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Steffen Beyer\nmailto:STBEY@cpan.org\nhttp://www.engelschall.com/u/sb/download/\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2000 - 2013 by Steffen Beyer. All rights reserved.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This package is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself, i.e., under the terms of the \"Artistic License\" or the \"GNU General Public\nLicense\".\n\nThe C library at the core of this Perl module can additionally be redistributed and/or modified\nunder the terms of the \"GNU Library General Public License\".\n\nPlease refer to the files \"Artistic.txt\", \"GNUGPL.txt\" and \"GNULGPL.txt\" in this distribution\nfor details!\n",
            "subsections": []
        },
        "DISCLAIMER": {
            "content": "This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\nwithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nSee the \"GNU General Public License\" for more details.\n",
            "subsections": []
        }
    },
    "summary": "Bit::Vector::Overload - Overloaded operators add-on for Bit::Vector",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "Vector",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Vector/3/json"
        },
        {
            "name": "String",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/String/3/json"
        }
    ]
}