uint64

  • Thread starter Thread starter Bob Allen
  • Start date Start date
B

Bob Allen

I have no idea what group to ask this in so i will start here. Does anyone
have a good way of compressing a 19 digit number down to the smallest
possible number? I have a delima of having a uint64 19 digit number that i
need to fit into a 10 digit space. I have tried using byte comparisons and a
few others but it gets me down to about 18 digits. Any help is greatly
appreciated.

Thanks;
bob;
 
Bob said:
I have no idea what group to ask this in so i will start here. Does anyone
have a good way of compressing a 19 digit number down to the smallest
possible number? I have a delima of having a uint64 19 digit number that i
need to fit into a 10 digit space. I have tried using byte comparisons and a
few others but it gets me down to about 18 digits. Any help is greatly
appreciated.

Use a single? That'll discard the least significant bits, but will
store the magnitude and most significant bits.
 
Bob Allen said:
[...] I have a dilemma of having a uint64 19 digit
number that I need to fit into a 10 digit space.

No way.

Try a ng on compression if you want to know why.
 
Bob Allen said:
I have no idea what group to ask this in so i will start here. Does anyone
have a good way of compressing a 19 digit number down to the smallest
possible number? I have a delima of having a uint64 19 digit number that i
need to fit into a 10 digit space. I have tried using byte comparisons and a
few others but it gets me down to about 18 digits. Any help is greatly
appreciated.

You can't do it, due to the pigeon-hole principle. You can't get it
down to 18 digits, either.

Consider how many 19-digit numbers there are.
Then consider how many 18-digit numbers there are.
How could you possibly represent each different 19-digit number as a
different 18-digit number when there are more 19-digit numbers?
 
Bob Allen said:
I have no idea what group to ask this in so i will start here. Does anyone have a good way of
compressing a 19 digit number down to the smallest possible number? I have a delima of having a
uint64 19 digit number that i need to fit into a 10 digit space. I have tried using byte
comparisons and a few others but it gets me down to about 18 digits. Any help is greatly
appreciated.

I am a bit unclear about your dilemma.
What do you mean by "a 10 digit space"?
10 bytes?
10 ASCII chars?
Uint32?

What does the data represent?
Why are you limited?

Depending on how you answer, it is possible that we can help you

Bill
 
If the 19 bit number can be any 19-bit number, then the only way to do
it is to throw away 9 bits of information.
 
Bob Allen said:
I have no idea what group to ask this in so i will start here. Does anyone
have a good way of compressing a 19 digit number down to the smallest
possible number?

byte Compress(uint64 x) {return (x>0)?1:0;}

That compresses it to just 1 bit! (ps. you didn't specify, but I'm
assuming we can use lossy compression...)
 
19 digit to 10 digit? If what you ask is literally, it's easy. Just increase
the base.

You see that a 12 digit binary number can be neatly "compress" to 4 digit
octal number or 3 digit hexadecimal. Got it?

111111111111b = 7777o = FFFh

Do it likewise for your 19 digit number.
 
Consider how many 19-digit numbers there are.
Then consider how many 18-digit numbers there are.
How could you possibly represent each different 19-digit number as a
different 18-digit number when there are more 19-digit numbers?

Depends on the number of signifigant figures you need to keep. If its not greater than the range offered by a 64bit
number it would be possible using Shemitz's method. You just have to realise you will lose precision as the number gets
higher, and the problems with equality comparisons. Otherwise you'll need to look at an alternative solution and some
sort of BigInteger class. This would be larger than 64bits and incure an overhead in manipulating it but you could now
store your integer with full precision.
 
Chris Chilvers said:
Depends on the number of signifigant figures you need to keep.

Sure - but there was no indication from the OP that a lossy conversion
was acceptable.
 
Bob said:
I have no idea what group to ask this in so i will start here. Does anyone
have a good way of compressing a 19 digit number down to the smallest
possible number? I have a delima of having a uint64 19 digit number that i
need to fit into a 10 digit space. I have tried using byte comparisons and a
few others but it gets me down to about 18 digits. Any help is greatly
appreciated.

Thanks;
bob;

You have to give more information on what you are trying to do, in order
for someone to be able to help you.

You simply can't compress data that is as small as you are talking
about. Any compression algorithm would add much more overhead than the
number of bits it would be able to elliminate.

To be able to reduce the data size you have to consider how the data is
used to identify what part of it is not used at all. For an example if
the number would represent a date and time, like 20060430181723, you
know that for the digits that represent the seconds and minutes the
values 60-99 is never used, for hours the values 24-99 is never used,
and so on.
 
Back
Top