Re: How short can I make it
Re: How short can I make it
- Subject: Re: How short can I make it
- From: Doug McNutt <email@hidden>
- Date: Fri, 14 Oct 2011 14:30:41 -0600
At 20:07 -0400 10/13/11, Mark J. Reed wrote:
>The logic is the same (though base 64, as a power of 2, can be implemented much more efficiently on computer hardware), but it's worth pointing out that Base64 encoding is not a traditional numeric representation. The name doesn't lie - it is certainly a true base-64 format. But the selection of digits does not follow the usual pattern (couldn't, really, since the usual pattern runs out at 36). For instance, 0-9 are not represented by themselves (the value of 0 is represented by 'A', while '0' represents 52), upper and lowercase are distinct ('a' represents 26), and the digit set includes punctuation marks ('+' for 62, '/' for 63).
>
>On Thursday, October 13, 2011, Doug McNutt <<mailto:email@hidden>email@hidden> wrote:
>> At 15:04 -0700 10/13/11, Stan Cleveland wrote:
>>>On Oct 13, 2011, at 10:01 AM, Mark J. Reed wrote:
>>>
>>>>9 digits? Not in decimal - epoch time broke 10 digits in 2001. As I type this it's 1,318,524,834. That's 8 digits in hexadecimal. Or 6 digits in base 36 (0,1,2,3,4,5,6,7,8,9,a,b,c,d,...,z)...
>>>>
>>>Base 36? Very interesting. Do you have AS routines to share for doing conversions between decimal and base 36 and back again? Or even better, between any two bases in the range of, say, 2 to 36?
>>
>> Base 36 would be not much different from Base 64 here. There is lots of code for that.
>>
> > But then a simple loop doing integer divisions by 36 and using the remainder as the next digit in a result would be pretty simple unless AppleScript gets in the way.
Understanding that limits of Applescript. might forbid it. . .
What I was really thinking is to place the datecode into a 32 bit register with a shift capability into another register. Such things were once called the A and Q registers but now that bytes are stored backwards I donno.
The procedure would then be:
load a register with the current date code
create a blank string
repeat until register is null
{
shift 6 bits left
do a lookup in the base64 table for the 6 bit byte shifted out
add the found character - printable - to the string being prepared.
}
return the string
Part of the problem is that I come from a world of 48 bit doubles and 6 bit bytes with no such thing as lower case. The digits 0-9 were in fact represented by their 6 bit binary equivalents. There were lots of advantages to that. But IBM came along with 9 track tapes and the world wanted ASCII and lower case that came with it. I feel much the same with this OS 9 8500. My 1982 Jeep navigates the highways and my 1957 Piper Apache uses the same runways . . . when I can afford the avgas. Sigh.
But with lower case available the obvious base is 10 + 26*2. All you need is two more graphemes (+ and / as per Mark) and you have base 64. The "standard" table handles that but even base 62, with lower case, would be as easy as base 36 which requires divisions and remainders as opposed to shifts.
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden