Results 1 to 2 of 2

Thread: hex QByteArray to double?

  1. #1
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default hex QByteArray to double?

    Hi,

    I am trying to convert a hex array representation of a double back into a double. In .NET, this could be done with the BitConverter class, but I am having trouble doing it with a QByteArray created with hex values. Is this the correct approach, or what am I doing wrong?

    <code>
    bool success;
    QByteArray dbl("A0A869C0471445C1");
    double d = dbl.toDouble(&success);

    // success = false, d=0.000000

    // no problem converting decimal to double:
    QByteArray dbl2("123.567");
    d = dbl2.toDouble(&success);
    // success = true, d = 123.567
    </code>

    Thanks for your input,
    --tlt

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: hex QByteArray to double?

    u should try
    QByteArray::number ()

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. Replies: 2
    Last Post: 16th April 2009, 05:34
  3. QByteArray problem
    By Misenko in forum Qt Programming
    Replies: 17
    Last Post: 4th October 2008, 21:53
  4. Double Buffering for plot graphs
    By Tavit in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 13:10
  5. QDomElement to QByteArray ?
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 2nd May 2006, 17:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.