// ==========16 Convert decimal to floating point ===========
private void button1_Click(object sender, EventArgs e)
{
textBox2.Clear();
string hex = this.textBox1.Text.Trim();
uint num = uint.Parse(hex,
System.Globalization.NumberStyles.AllowHexSpecifier);
label3.Text = num.ToString();
byte[] floatValues = BitConverter.GetBytes(num);
float f = BitConverter.ToSingle(floatValues, 0);
textBox2.Text = Convert.ToDecimal(f) + "";
}
//======= Convert floating point to hexadecimal ===========
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
float f = Convert.ToSingle(textBox2.Text);
byte[] bytes = BitConverter.GetBytes(f);// Convert floating point to byte type
Array.Reverse(bytes);// Reverses the order of some elements in a one-dimensional array
textBox1.Text = BitConverter.ToString(bytes).Replace("-", "");
}
design sketch :
Technology
Daily Recommendation