ErrorsManager

bitwise

ErrorsManager.bitwise
IntegerobjectpublicErrorsManager.bitwiseRequiredIntegercodeRequiredIntegerbits
NameRequiredNullableTypedDefault Value
codeTrueFalseInteger
bitsTrueFalseInteger
NameRequiredNullableTypedDefault Value
ErrorsManager.bitwise
StringobjectpublicErrorsManager.bitwiseRequiredStringcodeRequiredIntegerbits
NameRequiredNullableTypedDefault Value
codeTrueFalseString
bitsTrueFalseInteger
NameRequiredNullableTypedDefault Value
ErrorsManager.bitwise
Array<Integer>objectpublicErrorsManager.bitwiseRequiredArray<Integer>codeRequiredIntegerbits
NameRequiredNullableTypedDefault Value
codeTrueFalseArray<Integer>
bitsTrueFalseInteger
NameRequiredNullableTypedDefault Value

El método bitwise es un método objeto nos permite hacer desplazamiento de Bit en el código de error tantos Bits como queramos, siendo el número de Bits positivo hacia la izquierda, creando los Bits requeridos; y siendo el número de Bits negativo hacia la derecha, eliminando consigo ese número de Bits por ese lado.

  • typepy
  • characters585
  • lines25
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from Assets.ErrorsManager import ErrorsManager

errors_manager:ErrorsManager = ErrorsManager()
options:tuple[int] = (-10, -5, -3, -1, 0, 1, 3, 5, 10)
value:int|str|list[int]

for i, value in enumerate((105, "pB", [41, 1])):

    bits:int

    for bits in options:

        new_value:int|str|list[int] = errors_manager.bitwise(value, bits)

        print((
            value, 
            errors_manager.to_array_binary(value), 
            bits, 
            new_value, 
            errors_manager.to_array_binary(new_value)
        ))

  • typejs
  • characters538
  • lines22
"use strict";

/** @type {ErrorsManager} */
const errors_manager = new ErrorsManager(), 
      /** @type {Array.<number>} */
      options = [-10, -5, -3, -1, 0, 1, 3, 5, 10];

[105, "pB", [41, 1]].forEach((value, i) => options.forEach(bits => {

    /** @type {number|String|Array.<number>} */
    const new_value = errors_manager.bitwise(value, bits);

    console.log([
        value, 
        errors_manager.to_array_binary(value), 
        bits, 
        new_value, 
        errors_manager.to_array_binary(new_value)
    ]);

}));

El resultado de estas pruebas son los siguientes:

ValorBinarioBitsDesplazadoBinario desplazado
105["101001", "000001"]-100["000000"]
105["101001", "000001"]-53["000011"]
105["101001", "000001"]-313["001101"]
105["101001", "000001"]-152["110100"]
105["101001", "000001"]0105["101001", "000001"]
105["101001", "000001"]1210["010010", "000011"]
105["101001", "000001"]3840["001000", "001101"]
105["101001", "000001"]53360["100000", "110100"]
105["101001", "000001"]10107520["000000", "010000", "011010"]
pB["101001", "000001"]-10A["000000"]
pB["101001", "000001"]-5DA["000011", "000000"]
pB["101001", "000001"]-3NA["001101", "000000"]
pB["101001", "000001"]-10A["110100", "000000"]
pB["101001", "000001"]0pB["101001", "000001"]
pB["101001", "000001"]1SD["010010", "000011"]
pB["101001", "000001"]3IN["001000", "001101"]
pB["101001", "000001"]5g0["100000", "110100"]
pB["101001", "000001"]10AQa["000000", "010000", "011010"]
[41, 1]["101001", "000001"]-10[0]["000000"]
[41, 1]["101001", "000001"]-5[3, 0]["000011", "000000"]
[41, 1]["101001", "000001"]-3[13, 0]["001101", "000000"]
[41, 1]["101001", "000001"]-1[52, 0]["110100", "000000"]
[41, 1]["101001", "000001"]0[41, 1]["101001", "000001"]
[41, 1]["101001", "000001"]1[18, 3]["010010", "000011"]
[41, 1]["101001", "000001"]3[8, 13]["001000", "001101"]
[41, 1]["101001", "000001"]5[32, 52]["100000", "110100"]
[41, 1]["101001", "000001"]10[0, 16, 26]["000000", "010000", "011010"]
ValorBinarioBitsDesplazadoBinario desplazado