Solved

Help with this C++ statement

Posted on 2006-05-25
Medium Priority
227 Views
Last Modified: 2010-04-23
Just wondering if anyone could offer some help with this C++ statement. I am having an issue with the memcpy portion of it:

memcpy(&dtest,&testdata[0],sizeof(double));//tc0
Pc0_A = fabs(dtest);

dtest is a double, testdata is a string array. The statetment above is used to copy the vaule in the array into dtest, which then has the absoulte value funtion performed on it, which will provide me with a number (coefficent). I have looked for a similar statement in VB 2005, but no dice. Any ideas?

Thanks

Brad
0
Question by:bradbritton
• 2
3 Comments

LVL 52

Accepted Solution

Carl Tawn earned 1000 total points
ID: 16762556
Can you give an example, or two, of what value would be in testdata[0] and what value you would expect to get from fabs() ?
0

Author Comment

ID: 16762615
original data from tool...
testdata[0] = 0x00;
testdata[1] = 0x00;
testdata[2] = 0x00;
testdata[3] = 0x60;//96dec
testdata[4] = 0xD3;//211dec
testdata[5] = 0x4C;//76dec
testdata[6] = 0x10;//16dec
testdata[7] = 0x16;//22dec
testdata[8] = 0x04;
testdata[9] = 0x01;

data before memcpy...(
[0x0]      0x00 ''  //0.0
[0x1]      0x00 ''  //0.0
[0x2]      0x00 ''  //0.0
[0x3]      0x60 '`' //96
[0x4]      0xd3 'Ó' //211
[0x5]      0x4c 'L' //76
[0x6]      0x60 '`'//96
[0x7]      0xc1 'Á'//193
[0x8]      0x00 '' //00
[0x9]      0x00 '' //00

pc0_a (after memcpy and absolute value function)
8,545,947
0

Author Comment

ID: 16764702
I used the following code and now works A+++

TKS.

Public Sub convert_data()
Dim dtest As Double = Nothing
Dim pc0_A As Decimal

Dim b01, b02, b03, b04, b05, b06, b07, b08, b09, b10 As Integer

Dim testdata(9) As Byte

b10 = bytes(0)
b09 = bytes(1)
b08 = bytes(2)
b07 = bytes(3)
b06 = bytes(4)

b05 = bytes(5)
b04 = bytes(6)
b03 = bytes(7)
b02 = bytes(8)
b01 = bytes(9)

testdata(0) = b10
testdata(1) = b09
testdata(2) = b08
testdata(3) = b07
testdata(4) = b06
testdata(5) = b05
testdata(6) = b04
testdata(7) = b03
testdata(8) = b02
testdata(9) = b01

testdata(7) = ((b03 And &HF0) / &H10) + ((b02 And &HF) * &H10) + (b01 * &H80)
testdata(6) = (b04 And &HF) + ((b03 And &HF) * &H10)
testdata(8) = &H0
testdata(9) = &H0

dtest = BitConverter.ToDouble(testdata, 0)

pc0_A = Abs(dtest)

End Sub
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.