473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Math

hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

Oct 24 '07 #1
9 1454
DaveP,

The only way you are going to be able to get a smaller number in terms
of how many characters it takes up is going to be by changing the
representation of the number to a number in a system where the base is higer
than 10 (which is what you are using now). For example, your number in base
10, 18347868, would be represented in hexidecimal as:

117F75C

Which is one character shorter. You can increase it to 26, and maybe
get a greater compression (using characters a-z in the alphabet) or maybe 36
(using a-z, 0-9) or even 62 (a-z, A-Z, 0-9).

However, this is going to produce a string, so in terms of bytes, you
are going to use more bytes than you would storing it in four bytes in an
integer.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

Oct 24 '07 #2
DaveP <dv*****@sbcglobal.netwrote:
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back
Well, you could just take away 10000000... beyond that, we'd know more
information about what the IDs could be. Doing it just with maths, you
quickly run into the pigeon-hole principle:

http://en.wikipedia.org/wiki/Pigeonhole_principle

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 24 '07 #3
On Wed, 24 Oct 2007 10:46:17 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:
>hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

I am not quite clear what it is you want to do. I have two
suggestions that might, or might not, be what you want.

1. Purely to compress the string representation of the number you
could use Binary Coded Decimal (BCD) This packs two decimal digits
into a single byte, so your 1000000 would take up four bytes in packed
BCD. For example your 18347868 -{ 0x18 0x34 0x78 0x68 } in BCD,
four bytes.

2. If you want to reduce the actual size of the numbers used
internally then pick a reasonable sized prime number, like 1019, and
make all your Transaction IDs multiples of that number. Just store
T_ID / 1019 and multiply when you need to restore the full Transaction
ID.

T_ID Internal Representation
18347095 18005
18348114 18006
18349133 18007
18350152 18008

This means that you cannot use every possible Transaction ID, your
18347868 is not allowed for instance because it is not a multiple of
1019. If this is a problem for you then do not use this method.

rossum

Oct 24 '07 #4
What it is im doing..is piggy backing on another number imcomming from the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP

"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

Oct 24 '07 #5
On Wed, 24 Oct 2007 12:40:51 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:
>What it is im doing..is piggy backing on another number imcomming from the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP
Two suggestions:

1 Just use as many least significant digits of the incoming ID as you
can and hope that your ID is enough to distinguish where the truncated
numbers match.

2 You need a bigger data field.

rossum
>
"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
>hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP
Oct 25 '07 #6
i think im screwd...
this field is a must at 20 max characters cant change
its a hl7 definition
i'll come up with somthing...
thanks alot for all the help
DaveP
"rossum" <ro******@coldmail.comwrote in message
news:qo********************************@4ax.com...
On Wed, 24 Oct 2007 12:40:51 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:
>>What it is im doing..is piggy backing on another number imcomming from the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming
ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP

Two suggestions:

1 Just use as many least significant digits of the incoming ID as you
can and hope that your ID is enough to distinguish where the truncated
numbers match.

2 You need a bigger data field.

rossum
>>
"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
>>hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

Oct 25 '07 #7
Could you express myID in hexadecimal before concatenating (I assume myID is
numeric). That will take fewer digits. The receiving application can
recover the original myID when it needs it.

Of course you could use a higher base than 16 (e.g. 34, using 0-1, A-Z, or
even higher using all printable characters).

"DaveP" <dv*****@sbcglobal.netwrote in message
news:yT******************@newssvr27.news.prodigy.n et...
>i think im screwd...
this field is a must at 20 max characters cant change
its a hl7 definition
i'll come up with somthing...
thanks alot for all the help
DaveP
"rossum" <ro******@coldmail.comwrote in message
news:qo********************************@4ax.com...
>On Wed, 24 Oct 2007 12:40:51 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:
>>>What it is im doing..is piggy backing on another number imcomming from
the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming
ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP

Two suggestions:

1 Just use as many least significant digits of the incoming ID as you
can and hope that your ID is enough to distinguish where the truncated
numbers match.

2 You need a bigger data field.

rossum
>>>
"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and
then
back

TIA
DaveP



Oct 25 '07 #8
On Thu, 25 Oct 2007 19:11:26 GMT, "DaveP" <dv*****@sbcglobal.net>
wrote:
>i think im screwd...
this field is a must at 20 max characters cant change
its a hl7 definition
i'll come up with somthing...
thanks alot for all the help
DaveP
Would it be easier to add a new field rather than change an existing
one?

rossum
>

"rossum" <ro******@coldmail.comwrote in message
news:qo********************************@4ax.com.. .
>On Wed, 24 Oct 2007 12:40:51 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:
>>>What it is im doing..is piggy backing on another number imcomming from the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming
ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP

Two suggestions:

1 Just use as many least significant digits of the incoming ID as you
can and hope that your ID is enough to distinguish where the truncated
numbers match.

2 You need a bigger data field.

rossum
>>>
"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com...
hi all.....
i have Transaction ids 1000000 or greater in size

i want to do a math computation to represent any number in smaller
digits...

example
838 some math function(s) would calculate back to starting number

starting number 18347868 calculate some math to smaller number and then
back

TIA
DaveP

Oct 25 '07 #9
im not in charge of that...this is a specification of ansi edi
transactions..this acct number is 20 characters.
So im trying to figure out a way to piggy back on a incomming acct no...with
our Trans Number
id.....

Thanks Alot
DAVEP
"rossum" <ro******@coldmail.comwrote in message
news:gr********************************@4ax.com...
On Thu, 25 Oct 2007 19:11:26 GMT, "DaveP" <dv*****@sbcglobal.net>
wrote:
>>i think im screwd...
this field is a must at 20 max characters cant change
its a hl7 definition
i'll come up with somthing...
thanks alot for all the help
DaveP
Would it be easier to add a new field rather than change an existing
one?

rossum
>>

"rossum" <ro******@coldmail.comwrote in message
news:qo********************************@4ax.com. ..
>>On Wed, 24 Oct 2007 12:40:51 -0700, "DaveP" <dv*****@sbcglobal.net>
wrote:

What it is im doing..is piggy backing on another number imcomming from
the
outside world
this number is then sent to another company
now where my number is concatenated to the end of the cust incomming
ID+MYID
The resulting string is to large for the Data Implementation

used for return reporting to identify the incomming customer prior
transaction , the myid part is our transaction id

Tks
DaveP

Two suggestions:

1 Just use as many least significant digits of the incoming ID as you
can and hope that your ID is enough to distinguish where the truncated
numbers match.

2 You need a bigger data field.

rossum
"DaveP" <dv*****@sbcglobal.netwrote in message
news:xw**************@nlpi068.nbdc.sbc.com.. .
hi all.....
i have Transaction ids 1000000 or greater in size
>
i want to do a math computation to represent any number in smaller
digits...
>
example
838 some math function(s) would calculate back to starting number
>
starting number 18347868 calculate some math to smaller number and
then
back
>
TIA
DaveP
>
>
>


Oct 25 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
1
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
7
by: bravesplace | last post by:
Hello, I am using the folling funtion to round a number to a single digit on my form: function round1(num) { return Math.round(num*1)/1 }
110
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
by: kirby.urner | last post by:
Cyber-curricula have a leveling aspect, as kids nearer Katrina's epicenter tune in and bliss out on 'Warriors of the Net' (why wait for stupid big dummy textbooks to catch up?). They feel more...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.