Hi,
Has anyone got sample RPG code that works out the checksum of a string?
What code should do:
- take the FIX message stream (string)
- loop through each byte (character):
1) determine the integer value of that byte (e.g. 'A'=65, 'a'=97, '.'=46, note will be <= 256)
2) accumulate (continue to add values to a variable) the integer value of that byte to a variable in order to obtain the sum of the integer value of each byte in the FIX message stream
- compute the modulus (integer of the remainder following division also known as "mod" (C/C++ and Java use "%" for this)) of the sum obtained above when divided by 256
- take the modulus integer value (will always be less than 256 since it was mod'd by 256) and represent it as a 3 character sting with leading zeros if necessary
- use the above 3 character string as the value for Checksum (tag 10)
WP
Has anyone got sample RPG code that works out the checksum of a string?
What code should do:
- take the FIX message stream (string)
- loop through each byte (character):
1) determine the integer value of that byte (e.g. 'A'=65, 'a'=97, '.'=46, note will be <= 256)
2) accumulate (continue to add values to a variable) the integer value of that byte to a variable in order to obtain the sum of the integer value of each byte in the FIX message stream
- compute the modulus (integer of the remainder following division also known as "mod" (C/C++ and Java use "%" for this)) of the sum obtained above when divided by 256
- take the modulus integer value (will always be less than 256 since it was mod'd by 256) and represent it as a 3 character sting with leading zeros if necessary
- use the above 3 character string as the value for Checksum (tag 10)
WP