Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

[Question] Checksum creation

  • 11-07-2011 2: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