Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

[Question] Checksum creation

  • 11-07-2011 03:26PM
    #1
    Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭


    I have an old project I have taken over. I need to rewrite an interfacing application. In the development notes there is this line:

    "To calculate the checksum add each character as an unsigned binary number, take the lower 16 bits of the total and perform a 2's complement. The checksum field is the result represented by four hex digits."


    Nobody exists that created this application so I only have these notes to go on. What is the general interpretation of what is being asked here? I can see more than 2!!


Comments

  • Registered Users, Registered Users 2 Posts: 981 ✭✭✭fasty


    It's manipulating bits in memory to produce a token to help detect errors.

    What part don't you get?


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    fasty wrote: »
    It's manipulating bits in memory to produce a token to help detect errors.

    What part don't you get?

    I know what a checksum is. I have to write some code to take the string and do this :
    "...add each character as an unsigned binary number, take the lower 16 bits of the total and perform a 2's complement. The checksum field is the result represented by four hex digits."

    I am wondering what peoples interpretation of that line is. For example, suppose the string is "This is a test string". Should I convert each character, including space, to binary the add them up, take the first 16 bits and 2's complement it? Or do you think it is the sum of the total string in binary before 2's?

    I suppose it's a general question on interpretation rather than a 'How to' code question.


  • Registered Users, Registered Users 2 Posts: 586 ✭✭✭Aswerty


    I interpreted it as:

    Get the sum of each of the individual characters.
    Get the 16 LS-bits.
    Perform a 2's compliment on said LS-bits.

    Just getting the 16 LS-bits of the string would not make for a very strong checksum and I would assume this is not what they mean.


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    surely no interpertation required. you have a working old system.

    Based some data through and check the results.

    compare with your new code (both possible ways) and see which matches :=)


Advertisement