Results 1 to 7 of 7

Thread: HEX addition, subtraction LRC ASCII

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default HEX addition, subtraction LRC ASCII

    Trying to do ASCII LRC calculation, so I have hex values stored in a QByteArray, something in the lines of 01050500FF00, I need to add these values together, then subtract the result from FF, and add 1 to get the LRC..

    in short :
    1- Step1 = Sum Hex bytes of given QByteArray
    2- Step2 = "FF" - Step1 (take the right part)
    3- Step3 = Step2 + 1

    Example :

    1 - "01050500FF00", LRC should be F6
    0+1+0+5+0+5+0+0+F+F+0+0 = 010A
    FF - 0A = F5
    F5 +1 = F6

    2 - "010505000000", LRC should be F5
    ie 0+1+0+5+0+5+0+0+0+0+0+0 = 0B
    FF - 0B = F4
    F4 + 1 = F5

    My question is there an easy way to do Hex addition and subtraction in QT? if so how? or do I convert to decimal... case 'A' : a[i] = 11;break;... and so on..

    tnx for any help..

    p.s. C++
    Last edited by phakorr; 28th April 2014 at 10:48. Reason: added p.s. to tell that this is for C++

Similar Threads

  1. socketnotifier addition to qapplication.
    By vijay523201 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 21st July 2013, 11:17
  2. Hex to Ascii and Ascii to Hex Problem
    By havoc in forum Newbie
    Replies: 6
    Last Post: 20th July 2013, 23:24
  3. QGraphicsScene and dynamic addition of QGraphicsItems
    By El Bazza in forum Qt Programming
    Replies: 7
    Last Post: 15th September 2012, 07:57
  4. vertical scrollbar subtraction from the screen width
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2011, 09:16
  5. Addition of images
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2007, 12:38

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.