C# - Convert MBF Single And Double To IEEE?

Jun 4, 2010

Follow-Up available: There's a follow-up with further details, see Convert MBF to IEEE.

I've got some legacy data which is still in use, reading the binary files is not the problem, the number format is. All floating point numbers are saved in MBF format (Single and Double). I've found a topic about that on the MSDN boards but that one only deals with Single values. I'd also would like to stay away from API-Calls as far as I can.

Edit: Just in case somebody needs it, here is the VB.NET Code (it's Option Strict compliant) I ended up with (feel free to convert it to C# and edit it in):

''' <summary>Converts a MBF Single to an IEEE Single</summary>
''' <param name="src">The MBF Single value</param>
''' <returns>The converted IEEE Single value</returns>

[Code]...

View 2 Replies


ADVERTISEMENT

Convert Single Precision Floating Point Numbers To IEEE 754 Hex And Back?

Aug 12, 2009

Private Function SingleToIEEE754Hex(ByVal pValue As Single) As String

[Code]...

View 1 Replies

Convert 4 Bytes To IEEE 754 32-bit Float?

Mar 15, 2011

I am receiving a data stream which contains 4 bytes of data which need to be converted to a 32-bit float (IEEE 754). This was easy to do in C as I created a union with a 4-byte array and a 32-bit float. Job done. However I have no idea how to accomplish this in VB (pls note I do not code in VB).

View 3 Replies

Convert Single Digit To Double Digit?

May 28, 2011

I'm making a project that randomly picks a number from an array, but if it picks a number less than 10 then the number is a single instead of a double.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim N(2) As Integer
N(0) = "0" & 1
N(1) = "0" & 2
N(2) = "0" & 3

[Code]...

View 1 Replies

Intercept Single Or Double Mouse Click - Only Execute Double Click Code On Double Click?

Jan 27, 2011

I have a situation where I am handling both single & double mouse click events on a form. In both cases something has to be loaded, however when a double click occurs, I do not wish to execute the code attached to the single click event.Is there a way to intercept the mouse click's and check if double or single and then execute the right event appropriately?

View 2 Replies

Comparing A Single To A Double?

Oct 19, 2010

Here's my test code:

Dim testSingle As Single = 7.2
Dim testSingleF As Single = 7.2F
Dim testDouble As Double = 7.2

[code].....

View 2 Replies

Double And Single Quotes In String?

May 12, 2009

I have a problem with double and single quotes in a string.I have a textbox where i take a string from.In the textbox are double quotes and single quotes quotes.Problem is that if i return the string all the single quotes are replaced by double quotes.How can i get it to keep the single quotes as single quotes?

View 4 Replies

Implicit Conversion From Double To Single

Jun 13, 2011

[Code]...

The code compiles and seems to run correctly, but is underlined with the message "Implicit Conversion from 'Double' to 'Single'" Why would this be an implicit conversion if each of the variables is cast as a Single? Is this something I should worry about or change?

View 2 Replies

Put A Single Double Quote As A String?

Mar 15, 2011

It would seem to be Dim MyString as String = """""" but VB doesn't like that.

View 2 Replies

Check Single And Double Bytes Character?

Feb 16, 2011

How to check the Single byte character (e.g. English) and Double bytes character(e.g. Chinese) ?

Since I want to printing out their code which are representing in Hex.

However, Single byte character is using 2 digits of Hex. And Double bytes character is using 4 digits of Hex.

So, how can I check them and output with more readable pattern ?

input likes: 微軟 Microsoft output likes: B74C B36E 4D 69 63 72 6F 73 6F 66 74

View 1 Replies

Reverse Casting - Single Back To Double?

Nov 10, 2011

I wanted to know if it's possible - after casting a double to a single, to turn it back into a double again? i tried doing something like:

Dim x_double as double = 12345678.987654321d
Dim x_single as single=x_double
x_doubble=Cdbl(x_single)

but it doesn't give me the original value.

View 2 Replies

Reverse Casting \ Single Back To Double?

Mar 30, 2010

Reverse casting? Single back to Double

View 5 Replies

Access Single Bytes That Form A Double Variable?

Sep 20, 2009

How can I get access in a fast way to the single bytes that form a double variable?

In pseudo-code I want to do something like this:

Dim myDouble as Double
Dim myArray(7) as Byte
myArray = myDouble

'continue doing things with the single bytes

The code is meant for use in a I/O-handler. The double-variables have to be sent / received via TCP. For this purpose they shall be put into / assembled from I/O-buffers.

View 2 Replies

Saving A Text Field That May Contain A Single Of Double Quote?

Jun 16, 2010

I am saving a text field that may contain a single of double quote.' or "If i use a double quote in my SQL save funciton I can save and use single Quotes. When I use a Single quote I can save Double Quotes. Yet not both.People use both, so I would like to know how I could change the delimiter to something other than a Double Quote for my text saves

View 3 Replies

Calculator Application - Use Datatype - Variables Be Single Double Decimal ?

Mar 11, 2009

I am writing an calculator application and i dont know what datatype to use. i mean should the variables be single, double, decimal...?

View 1 Replies

Set Folder Options Single Or Double Click To Open Item?

Nov 4, 2010

I would like to be able to set the following settings in the folder options:

- single click to open an item
- double click to open an item

I am using Visual basic 2008 Express edition.

View 2 Replies

VS 2008 - Option Strict Continued - Gives Me The Going From Double To A Single Error

Oct 13, 2009

Quick code example:

v1.magnitude = myVectors(c).magnitude * 0.95

I have a vector class...and the magnitude is single precision...Now the problem is this, when I run this with option strict on, it gives me the going from double to a single error...Why? Does multiplication imply double precision?

So with option strict on, can you not multiply single precision numbers together and assign them to another single precision variable without first convert.tosingle?

What is the point of this? I am currently changing hundreds of lines of code in a project that runs perfectly...

View 22 Replies

Converting Bytes To IEEE Float And Vice Versa?

Dec 6, 2009

I am reading and writing binary data through a serial port and must (a) reassemble the incoming four bytes that make up a IEEE single-precision float into an actual float, and (b) disassemble a float into its four constituent bytes before squirting them through the serial port.

I am using VB.NET 2008. In VB6, I could use the LSET command, as in:

Code:
Private Type typByteArray
B(1 To 4) As Byte
End Type

[Code]....

But of course this code won't work in VB.NET. In C it would be easy to handle situations like this by using unions, but VB.NET doesn't support them.

View 2 Replies

Convert A Double X To A Decimal Y?

Oct 5, 2011

Let's say I want to convert a Double x to a Decimal y. There's a lot of ways to do that:

1. var y = Convert.ToDecimal(x); // Dim y = Convert.ToDecimal(x)
2. var y = new Decimal(x); // Dim y = new Decimal(x)
3. var y = (decimal)x; // Dim y = CType(x, Decimal)
4. -- no C# equivalent -- // Dim y = CDec(x)

Functionally, all of the above do the same thing (as far as I can tell). Other than personal taste and style, is there a particular reason to choose one option over the other?

EDIT: This is the IL generated by compiling the three C# options in a Release configuration:

1. call valuetype [mscorlib]System.Decimal [mscorlib]System.Convert::ToDecimal(float64)
--> which calls System.Decimal::op_Explicit(float64)

[Code]....

View 3 Replies

Convert SMS Number To Double?

May 3, 2012

I am trying to convert an SMS to double. I'm creating a monitoring system where values like "45.2" are sent to another modem.

I would like to convert 45.2 (which I think is string initially and placed in a textbox) to double so I can do comparison upon receiving it.[code]...

View 2 Replies

Convert String To Double - VB?

Jul 23, 2009

Is there an efficient method in VB to check if a string can be converted to a double?I'm currently doing this by trying to convert the string to a double and then seeing if it throws an exception. But this seems to be slowing down my application.

Try
' if number then format it.
current = CDbl(x)

[code].....

View 3 Replies

How To Convert String To Double

Aug 30, 2010

I want to convert string to double.

[Code]...

num should be 1.5432 but i get 15432 How can i get as it is in the string?

View 16 Replies

Sql Insert Convert To Double

Oct 15, 2009

In my vb.net code, I had the following code:

[Code]...

View 3 Replies

Cannnot Convert From String To Double?

Mar 24, 2010

Iam using VB 2005 on Vista This is a sample of what I am doing:

Public Class Form 1 Dim WC As String Private Sub Button1_Click

[Code]...

How do I get around this? What I am trying to do is, I really want to use TextBox's for input to enter numbers when the program is running and I also want a MsgBox to appear if an input is not entered because these numbers are important to a final formula further down.

View 2 Replies

Convert Double To A Timespan (date)

Sep 23, 2009

Let just say I have an Integer like 10,000 (that's the VALUE in want to reach). So, I have another integer like 2500 (that's my current VALUE). Third I have another Integer about 350 PER HOUR. To reach 10,000 I need 7,500 (well I already have 2,500). How long must I wait to reach the 10,000 when the increase is about 350 a Hour. Okay, that's easy: 7,500 / 350 = 21,428571 Hours. BUT how can I convert this double to a timespan? Or how is it possible to add this double value to the current Date to get the Date + Time when I reach the Value?

View 2 Replies

Convert String Into Double Array

Aug 4, 2009

How to convert a string array into double array?

View 5 Replies

Convert String To Double Array?

Apr 18, 2012

I need to take this string:

Dim tmpTry As String = "10, 20, 30, 40, 50, 52, 20, 20, 10, 35, 3, 8, 47, 7, 2, 5, 55, 8, 0, 0, 6, 55, 0, 2, 12, 0, 0, 21, 14, 0, 3"

And convert it to a double array:

Dim arrNumOfVisits As Double() = New Double(tmpTry) {}

How do i go about doing that?

FYI the arrNumOfVisits goes into a ParamArray System.Collections.IEnumerable()

View 1 Replies

Datatable - Convert String To Double?

Jun 21, 2012

data table contain column named as Fld_primary. this column contain value like 0.00 it is double datatype in mysql table.i want store that datatable value in double variable. am always getting error when i convert to double datatype.

my code
-------
Dim ds5 As dataset1.DTSUMDataTable = TA5.GetData(users)
Dim dttot As Double
dttot = CType(ds5("fld_primary").ToString, Double)

Error:Conversion from string "fld_primary" to type 'Integer' is not valid.

View 5 Replies

VS 2005 - How To Convert String To Double

Mar 3, 2010

I am trying to convert a string to double and it is giving error. Bye the way it is not giving error on my PC but it gives on some pc's where other clients are using. String is retrieved from xml data.

<data><vitals>
<username>aiglemedia</username>
<balance>49.60</balance>
</vitals></data>
vb code
Dim curBalance As Double
xmlNode = xmlDoc.GetElementsByTagName("vitals")......xmlDoc contains the above xml data
curBalance = System.Convert.ToDouble(xmlNode.Item(0).Item("balance").InnerText)... I think so error is on this line.

Below is the link for the error given by the client who is using the app [URL]

View 3 Replies

VS 2010 Convert Currency To Double

Apr 28, 2011

I have a value $17.50 as a string..how would i convert it to a double 17.50?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved