This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperadorAND | |
{ | |
static void Main() | |
{ | |
byte A = 121; | |
byte B = 113; | |
byte resultado =(byte) (A & B); | |
Console.WriteLine(Convert.ToString(resultado,2)); // Imprime 1110001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperadorOR | |
{ | |
static void Main() | |
{ | |
byte A = 39; | |
byte B = 42; | |
byte resultado = (byte) (A|B); | |
Console.WriteLine(Convert.ToString(resultado,2)); // Imprime 101111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperadorXOR | |
{ | |
static void Main() | |
{ | |
byte A = 17; | |
byte B = 29; | |
byte resultado = (byte)(A ^ B); | |
Console.WriteLine(Convert.ToString(resultado, 2)); // Imprime 1100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DesplazamientoIzquierda | |
{ | |
static void Main() | |
{ | |
byte byte1 = 7; | |
byte byte2 = (byte)(byte1 << 3); | |
Console.WriteLine(byte2); // Imprime: 56 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DesplazamientoIzquierdaPotenciasDeDos | |
{ | |
static void Main() | |
{ | |
System.Diagnostics.Stopwatch cronometro = new System.Diagnostics.Stopwatch(); | |
cronometro.Start(); | |
byte potenciaConBitwise = 1 << 7; | |
cronometro.Stop(); | |
Console.WriteLine("Tiempo transcurrido: {0}", cronometro.Elapsed.TotalMilliseconds); // 0.0020 (puede variar) | |
cronometro.Reset(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DesplazamientoDerecha | |
{ | |
static void Main() | |
{ | |
byte byte1 = 7; | |
byte byte2 = (byte)(byte1 >> 2); | |
Console.WriteLine(byte2); // Imprime: 1 (decimal) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RendimientoDesplazamientoDerecha | |
{ | |
static void Main() | |
{ | |
System.Diagnostics.Stopwatch cronometro = new System.Diagnostics.Stopwatch(); | |
cronometro.Start(); | |
byte divisionConBitWise = 3 >> 2; | |
cronometro.Stop(); | |
Console.WriteLine("Tiempo transcurrido: {0}", cronometro.Elapsed.TotalMilliseconds); // 0.0005 (puede variar) | |
cronometro.Reset(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DivisionPorCeroValoresInfinitos | |
{ | |
static void Main() | |
{ | |
Console.WriteLine(1.0 / 0.0); // Infinity | |
Console.WriteLine(-1.0 / 0.0); // -Infinity | |
Console.WriteLine(1.0 / -0.0); // -Infinity | |
Console.WriteLine(-1.0 / -0.0); // Infinity | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class doubleVSdecimal | |
{ | |
static void Main() | |
{ | |
Random aleatorio = new Random(); | |
decimal[] decimales = new decimal[100]; | |
double[] doubles = new double[100]; | |
for (int i = 0; i < 100; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AgnioParOImpar | |
{ | |
static void Main() | |
{ | |
bool b = true; | |
// esta línea convierte de manera automática el valor de la variable b a texto | |
Console.WriteLine(b); | |
// obtiene el día del año |