1. String compression

--=======AVGMAIL-3FDF13F749BC=======

------=_NextPart_000_0009_01C3C43B.88D9DE40

I noticed that people were concerned about string memory usage so I came up with
this.
To my knowlege an integer is stored as an integer regardless
of its length, (since computers store such things in binary).
Please correct me if I'm wrong. 
Its not much but a good start, modify it as u see fit.

include machine.e
-- integer = p_ints(integer digit, integer digit)
-- Pack two integers onto one integer.
-- Returns a single integer.
global function p_ints(integer a,integer b)
sequence s
atom n
   s = int_to_bits(a,16)
   s &= int_to_bits(b,16)
   n = bits_to_int(s)
   return n
end function
-- sequence = u_ints(integer digit)
-- Unpack integer into two integers.
-- Returns a double integer sequence.
global function u_ints(integer n)
sequence s
object a
   s = int_to_bits(n,32)
   a = bits_to_int(s[1..16])
   a &= bits_to_int(s[17..32])
   return a
end function

I have another routine that compresses whole words into an integer, but since
two different words can equal the same integer I run into problems reversing it.
(it only works for certain words about 5 - 10% of the time).
(95% of the time I get different run_time errors.)
I have three theorys to over come this.
1. Store a digit on the end as a seed to reversing the word.
eg: the length of the word.
2. Compress word to a decimal atom to contain a seed in itself.
3. It cannot be done!

 If any one knows were I can find related topics it be much helpfull. 







---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/03
------=_NextPart_000_0009_01C3C43B.88D9DE40
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I noticed that people were concerned about string 
memory usage so I came up with this.</FONT></DIV>
<DIV><FONT face=Arial size=2>To my knowlege an integer is stored as an integer 
regardless</FONT></DIV>
<DIV><FONT face=Arial size=2>of its length, (since computers store such 
things&nbsp;in binary).</FONT></DIV>
<DIV><FONT face=Arial size=2>Please correct me if I'm wrong. </FONT></DIV>
<DIV><FONT face=Arial size=2>Its not much but a good start, modify it as u see 
fit.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>include machine.e<BR>-- integer = p_ints(integer 
digit, integer digit)<BR>--&nbsp;Pack two integers onto one integer.<BR>-- 
Returns a single integer.<BR>global function p_ints(integer a,integer 
b)<BR>sequence s<BR>atom n<BR>&nbsp;&nbsp; s = int_to_bits(a,16)<BR>&nbsp;&nbsp;
s &amp;= int_to_bits(b,16)<BR>&nbsp;&nbsp; n = bits_to_int(s)<BR>&nbsp;&nbsp; 
return n<BR>end function<BR>-- sequence = u_ints(integer digit)<BR>-- Unpack 
integer into two integers.<BR>-- Returns a double integer sequence.<BR>global 
function u_ints(integer n)<BR>sequence s<BR>object a<BR>&nbsp;&nbsp; s = 
int_to_bits(n,32)<BR>&nbsp;&nbsp; a = bits_to_int(s[1..16])<BR>&nbsp;&nbsp; a 
&amp;= bits_to_int(s[17..32])<BR>&nbsp;&nbsp; return a<BR>end 
function</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I have another routine that compresses whole words 
into an integer, but since two different words can equal the same integer I run 
into problems reversing it. (it only works for certain words about 5 - 10% of 
the time). </FONT></DIV>
<DIV><FONT face=Arial size=2>(95% of the time I get different run_time 
errors.)</FONT></DIV>
<DIV><FONT face=Arial size=2>I have three theorys to over come 
this.</FONT></DIV>
<DIV><FONT face=Arial size=2>1. Store a digit on the end as a&nbsp;seed to 
reversing the word.</FONT></DIV>
<DIV><FONT face=Arial size=2>eg: the length of the word.</FONT></DIV>
<DIV><FONT face=Arial size=2>2. Compress word to a decimal&nbsp;atom to contain 
a&nbsp;seed in itself.</FONT></DIV>
<DIV><FONT face=Arial size=2>3. It cannot be done!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;If any one knows were I can find related 
topics it be much&nbsp;helpfull.&nbsp;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><BR>---<BR>Outgoing mail is certified Virus 
Free.<BR>Checked by AVG anti-virus system (<A 
href="http://www.grisoft.com">http://www.grisoft.com</A>).<BR>Version: 6.0.551 /

------=_NextPart_000_0009_01C3C43B.88D9DE40--
--=======AVGMAIL-3FDF13F749BC=======
Content-Type: text/plain; x-avg=cert; charset=iso-8859-2
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Description: "AVG certification"

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/12/03

--=======AVGMAIL-3FDF13F749BC=======--

new topic     » topic index » view message » categorize

2. Re: String compression

My P4 has 3x1GB RD ram.
----- Original Message ----- 
From: "Brian Broker" <bkb at cnw.com>
To: <EUforum at topica.com>
Subject: RE: String compression


>
>
> If anybody was so concerned about string storage to implement such a
> scheme I'd tell them it's time to upgrade their system or start
> programming in lower level language...  Did you know you can buy a 512MB
> stick of PC100 RAM for less than $50?  That's less than 10 cents per
> Meg.  If I did my math right, that's over 31,000 characters per penny
> using a plain old sequence.
>
> Just a thought,
> -- Brian
>
> Hayden McKay wrote:
> > I noticed that people were concerned about string memory usage so I came
> > up with this.
> > To my knowlege an integer is stored as an integer regardless
> > of its length, (since computers store such things in binary).
> > Please correct me if I'm wrong.
> > Its not much but a good start, modify it as u see fit.
> >
> > include machine.e
> > -- integer = p_ints(integer digit, integer digit)
> > -- Pack two integers onto one integer.
> > -- Returns a single integer.
> > global function p_ints(integer a,integer b)
> > sequence s
> > atom n
> >    s = int_to_bits(a,16)
> >    s &= int_to_bits(b,16)
> >    n = bits_to_int(s)
> >    return n
> > end function
> > -- sequence = u_ints(integer digit)
> > -- Unpack integer into two integers.
> > -- Returns a double integer sequence.
> > global function u_ints(integer n)
> > sequence s
> > object a
> >    s = int_to_bits(n,32)
> >    a = bits_to_int(s[1..16])
> >    a &= bits_to_int(s[17..32])
> >    return a
> > end function
> >
> > I have another routine that compresses whole words into an integer, but
> > since two different words can equal the same integer I run into problems
> > reversing it. (it only works for certain words about 5 - 10% of the
> > time).
> > (95% of the time I get different run_time errors.)
> > I have three theorys to over come this.
> > 1. Store a digit on the end as a seed to reversing the word.
> > eg: the length of the word.
> > 2. Compress word to a decimal atom to contain a seed in itself.
> > 3. It cannot be done!
> >
> >  If any one knows were I can find related topics it be much helpfull.
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> -- 
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.551 / Virus Database: 343 - Release Date: 12/12/03
>


---



--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu