|
Thanks Dave, I thought you might respond! I think you've got it to the smallest, however I think that if I use base 26 for the first character and base 32 for the rest, it still only comes to 7 characters. I say this on an assumption that the machine will prefer base 32 calculations. I've written a DIV/MVR combination but thought that in the future a binary operation might be faster (I seem to remember that in other languages you could replace a DIV 32 with a 'move binary point 5 positions left' operation?). Brendan Bispham -----Original Message----- You can convert any 10 digit base 10 number to a valid object name using a maximum of 7 significant characters. An object name has to begin with A-Z, $, # or @. This gives you 29 possibilities for character 1. Subsequent characters can be any of these plus 0-9, _ and . giving you 41 possibilities for each character in positions 2 - 10. So let A through Z represent 0 through 26, $ represent 27, # represent 28, @ represent 29, 0 through 9 represent 30 through 39, _ represent 40 and . represent 41. As an object name is (a maximum of) 10 characters we can represent any number that will convert to base 41 as long as the leading digit does not go above 29. This gives us a highest number of (30(41**9))-1. So a decimal value of 9,999,999,999 would give 2-4-12-35-26-40-0 in base 41. This translates to "BDL5Z_0". Putting in the leading "zeroes" we get an object name of AAABDL5Z_0. Incidentally, Leif's solution of using a 4 byte binary representation not only fails to produce valid object names but can't represent numbers higher than 4,294,967,295. Decimal 9,999,999,999 requires 9 digits in hexadecimal. Dave Kahn, ABB Steward Ltd. +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.