Link to home
Start Free TrialLog in
Avatar of bradbritton
bradbritton

asked on

Help with this C++ statement

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
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bradbritton
bradbritton

ASKER

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
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