/[RomCheater]/trunk/Win32/libWin32/Win32/UI/IEEE754FloatConverter.cs
ViewVC logotype

Contents of /trunk/Win32/libWin32/Win32/UI/IEEE754FloatConverter.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88 - (show annotations) (download)
Wed May 9 20:52:20 2012 UTC (9 years, 4 months ago) by william
File size: 1495 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using libWin32.Win32.NumericConversion.IEEE754;
10
11 namespace System.Windows.Forms
12 {
13 public partial class IEEE754FloatConverter : UserControl
14 {
15 public IEEE754FloatConverter()
16 {
17 InitializeComponent();
18 txtIEEE754Float.ReadOnly = false;
19 txtFloat.ReadOnly = false;
20 btnConvertToFloat.PerformClick();
21 }
22
23 private void btnConvertToFloat_Click(object sender, EventArgs e)
24 {
25 ieee754FloatingPointConverter converter = new ieee754FloatingPointConverter();
26 converter.HexFloat = txtIEEE754Float.ToUInt32();
27 txtFloat.Text = string.Format("{0:R}", converter.Float);
28 }
29
30 private void btnConvertToIEEE754Float_Click(object sender, EventArgs e)
31 {
32 ieee754FloatingPointConverter converter = new ieee754FloatingPointConverter();
33 float f;
34 if (!float.TryParse(txtFloat.Text, out f))
35 {
36 MessageBox.Show("Failed to Convert: " + txtFloat.Text + " to a float.", "Float Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
37 return;
38 }
39 converter.Float = f;
40 txtIEEE754Float.Value = converter.HexFloat;
41 }
42 }
43 }

  ViewVC Help
Powered by ViewVC 1.1.22