I have a little problem I’m hoping someone can help me solve. First, a bit of background. Our application deals with RFID tags for animals. These are always 15 digit numbers like 124000123456789. Even though they are numbers, I never have to deal with them as numbers. Instead, I always treat them as strings. RFID readers are usually RS-232 devices that send the tag number over as a string, so that works out well.
Now I’m being asked to support a new kind of reader that works differently. I have the algorithm to convert from the reader byte structure to a 15 digit number. Unfortunately, 4D’s C_REAL variables are only precise to 13 digits, so my last 2-3 digits are incorrect. I’m hoping someone knows how to convert what I’m getting into a 15 digit string in some other way. Here is an example string coming across the wire: “02ABC877FAFB0200”. This represents 8 bytes in little endian ordering. The algorithm that was given me was to break the string into bytes (“02”, “AB”, “C8”, etc.) and then loop through each byte, converting it to decimal and applying a little math. For example: Hex “02” = Decimal 2. SubValue = 2 * (256^0) = 2 Hex “AB" = Decimal 171. Subvalue = 171 * (256^1) = 43776 Hex “C8" = Decimal 200. Subvalue = 200 * (256^2) = 13107200 Hex “77" = Decimal 119. Subvalue = 119 * (256^3) =1996488704 Hex “FA" = Decimal 250. Subvalue = 250 * (256^4) = 1073741824000 Hex “FB" = Decimal 251. Subvalue = 251 * (256^5) = 275977418571776 (4D gives 2.759774185718e+14) Hex “02" = Decimal 2. Subvalue = 2 * (256^6) = 562949953421312 (4D gives 5.629499534213e+14) Hex “00" = Decimal 0. Subvalue = 0 * (256^7) = 0 Once this is done, all the subvalue results are summed which should give the RFID number. In this case it should be 840003123456770. But 4D gives this: 8.400031234568e+14. As you can see, the last three digits are not correct. So, does anyone know a way to convert the string “02ABC877FAFB0200” to the string “840003123456770” within 4D’s limitations? Thanks. -- Cannon.Smith Synergy Farm Solutions Inc. Hill Spring, AB Canada 403-626-3236 <[email protected]> <www.synergyfarmsolutions.com> ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

