Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2 ushort remix to 1 int
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { // Lecture de l'état des zones const int addrDebut = 13; // Adresse debut dans le buffer pour un COM const int taillePlage = 7; // Définit la taille de la plage à scruter ushort[] arrLect = new ushort[taillePlage]; // Intrusion // 0: Zone 01 -> 16 // 1: Zone 17 -> 32 // 2: Zone 33 -> 48 // 3: Zone 49 -> 64 // 4: Zone 65 -> 80 // 5: Zone 81 -> 96 // 6: Zone 97 -> 112 arrLect[0] = 10; arrLect[1] = 65535; arrLect[2] = 65535; arrLect[3] = 65535; arrLect[4] = 65535; arrLect[5] = 65535; arrLect[6] = 65535; for (int numVarIntr = 1; numVarIntr <= 4; numVarIntr++) // Incrémente nom var sortie { int val = 0; for (int indexZone = 1; indexZone <= 16; indexZone++) // { // Détermine l'index du bit en fonction de la zone int indexBIT = indexZone + 7; // Gestion de l'inversion poids faible / poids fort if (indexZone > 8) indexBIT = indexZone - 9; // Réorganise les bits de la variable ushort mask = (ushort)(1 << indexBIT); int arrIndex = numVarIntr*2-2; val |= arrLect[arrIndex] & mask; arrIndex++; if(arrIndex<(taillePlage-1)) { val |= (arrLect[arrIndex] & mask) << 16; } } // Ecriture de la variable Console.WriteLine( "" ); Console.WriteLine( "numVarIntr: " + numVarIntr.ToString() ); Console.WriteLine( "BIN: " + "| 7|| 6|| 5|| 4|| 3|| 2|| 1|| 0|"); Console.WriteLine( "BIN: " + Convert.ToString(val, 2).PadLeft(32, '0') + " - DEC: " + val.ToString() ); } } } }
run
|
edit
|
history
|
help
0
Carnival 1.0
Inheritance
Generic Type Foreach and Exceptions
123.0
Covariance & Contravariance
Intuit // C# // listing_4.4 (StreamReader // input.txt)
עעעע
IsDivisibleV2
asdfsdgghjghkhj
adxcsaxsd