-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
35 lines (31 loc) · 980 Bytes
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace binary
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void updateOut()
{
// Calculate the sum in a branchless manner using bitwise operations
int sum = (bool128.Checked ? 128 : 0) |
(bool64.Checked ? 64 : 0) |
(bool32.Checked ? 32 : 0) |
(bool16.Checked ? 16 : 0) |
(bool8.Checked ? 8 : 0) |
(bool4.Checked ? 4 : 0) |
(bool2.Checked ? 2 : 0) |
(bool1.Checked ? 1 : 0);
outputBits.Text = sum.ToString();
}
private void bool_CheckedChanged(object sender, EventArgs e)
{
updateOut();
}
private void outputBits_TextChanged(object sender, EventArgs e)
{
//TODO: make a stable in/out system.
}
}
}