Help with this C++ statement

Posted on 2006-05-25
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:

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?


Question by:bradbritton
    LVL 52

    Accepted Solution

    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() ?

    Author Comment

    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)

    Author Comment

    I used the following code and now works A+++


     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

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

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

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

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now