Re: BCD List to HEX List

2006-08-03 Thread bryanjugglercryptographer
ohn Machin wrote: [EMAIL PROTECTED] wrote: For each nibble n of x means to take each 4 bit piece of the BCD integer as a value from zero to sixteen (though only 0 through 9 will appear), from most significant to least significant. The OP's input, unvaryingly through the whole thread, even

Re: BCD List to HEX List

2006-08-02 Thread H J van Rooyen
John Machin [EMAIL PROTECTED] wrote: | [EMAIL PROTECTED] wrote: | | My version assumes three subroutines: extracting | nibbles, shifting, and adding, Those are pretty simple, so I asked | if he needed them rather than presenting them. | Assuming we have | them, the algorithm is three lines

Re: BCD List to HEX List

2006-08-02 Thread bryanjugglercryptographer
John Machin wrote: [EMAIL PROTECTED] wrote: For each nibble n of x means to take each 4 bit piece of the BCD integer as a value from zero to sixteen (though only 0 through 9 will appear), from most significant to least significant. The OP's input, unvaryingly through the whole thread,

Re: BCD List to HEX List

2006-08-01 Thread John Machin
[EMAIL PROTECTED] wrote: John Machin wrote: [EMAIL PROTECTED] wrote: Philippe Martin wrote: Yes, I came here for the algorithm question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y)

Re: BCD List to HEX List

2006-08-01 Thread bryanjugglercryptographer
John Machin wrote: [EMAIL PROTECTED] wrote: John Machin wrote: [EMAIL PROTECTED] wrote: To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Yeah yeah yeah i.e. y = y * 10 + n he's

Re: BCD List to HEX List

2006-08-01 Thread John Machin
[EMAIL PROTECTED] wrote: My version assumes three subroutines: extracting nibbles, shifting, and adding, Those are pretty simple, so I asked if he needed them rather than presenting them. Assuming we have them, the algorithm is three lines long. Perhaps you could enlighten us by publishing

Re: BCD List to HEX List

2006-08-01 Thread bryanjugglercryptographer
John Machin wrote: [EMAIL PROTECTED] wrote: My version assumes three subroutines: extracting nibbles, shifting, and adding, Those are pretty simple, so I asked if he needed them rather than presenting them. Assuming we have them, the algorithm is three lines long. Perhaps you could

Re: BCD List to HEX List

2006-08-01 Thread John Machin
[EMAIL PROTECTED] wrote: John Machin wrote: [EMAIL PROTECTED] wrote: My version assumes three subroutines: extracting nibbles, shifting, and adding, Those are pretty simple, so I asked if he needed them rather than presenting them. Assuming we have them, the algorithm is three

Re: BCD List to HEX List

2006-07-31 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: Why are you avoiding naming the chip and its compiler? I must disagree on that one: There are many threads on this site where people just have fun talking algorithm. I'm not an algo. expert and I know there are many here. This is just like the very

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: Why are you avoiding naming the chip and its compiler? I must disagree on that one: There are many threads on this site where people just have fun talking algorithm. I'm not an algo. expert and I know there are many here. This

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: 3. How does the device manage to compute the 8-decimal-digit number that is your input?? What device manager ? think about it before being rude No device manager [noun] was mentioned. You may have inferred rudeness where astonishment

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: Yes I had arm in mind (for some reason) while it is the Smc8831

Re: BCD List to HEX List

2006-07-31 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: I actually need numbers much larger than 32 bits. What is the max size hex number you need? What is the application if you don't mind my asking? -- http://mail.python.org/mailman/listinfo/python-list

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: I actually need numbers much larger than 32 bits. What is the max size hex number you need? What is the application if you don't mind my asking? Well I am under NDA so I cannot tell you what the application is - I need numbers

Re: BCD List to HEX List

2006-07-31 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: Well I am under NDA so I cannot tell you what the application is - I need numbers (dec) with up to 24 digits. You actually need to represent numbers up to 10**24?? As I said, I went the other way - more data on the line (from dev 1 to dev 2) - but I

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: Well I am under NDA so I cannot tell you what the application is - I need numbers (dec) with up to 24 digits. You actually need to represent numbers up to 10**24?? As I said, I went the other way - more data on the line (from

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: Well I am under NDA so I cannot tell you what the application is - I need numbers (dec) with up to 24 digits. You actually need to represent numbers up to 10**24?? As I said, I went the other way - more data on the line (from

Re: BCD List to HEX List

2006-07-31 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: On device #1 no constraint for my purpose. On the smartcard, the tradeoff is between using EEPROM (plenty + slow + small life expectancy) for temp variables versus RAM (very little) ... but I do not think it is an issue eather in my case. Speed is what

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: On device #1 no constraint for my purpose. On the smartcard, the tradeoff is between using EEPROM (plenty + slow + small life expectancy) for temp variables versus RAM (very little) ... but I do not think it is an issue eather in my

Re: BCD List to HEX List

2006-07-31 Thread bryanjugglercryptographer
Philippe Martin wrote: Yes, I came here for the algorithm question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Do you need instruction on extracting nibbles, and shifting and adding

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
[EMAIL PROTECTED] wrote: Philippe Martin wrote: Yes, I came here for the algorithm question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Do you need instruction on extracting

Re: BCD List to HEX List

2006-07-31 Thread John Machin
[EMAIL PROTECTED] wrote: Philippe Martin wrote: Yes, I came here for the algorithm question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Yeah yeah yeah i.e. y = y * 10 + n he's

Re: BCD List to HEX List

2006-07-31 Thread John Machin
Philippe Martin wrote: Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: I actually need numbers much larger than 32 bits. ***NOW*** you tell us, after all the stuffing about re 32 bits. What is the max size hex number you need? What is the application if you don't mind

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote: So why don't you get a freely available bignum package, throw away the bits you don' t want, and just compile it and use it, instead of writing your own bug-ridden (see below) routines? Oh yeah, the bignum package might use long and you think that you don't have access to

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Sorry forgot a few answers/comments: John Machin wrote: SHOULD BE = currently add([6, 6], [4, 4] - [10, 10] True, thanks *** try - 10 instead of % 10 If the first operand is 19, you have a bug! This might save a few CPU cycles on your smartcard can it ? each array value will be [0..9]

Re: BCD List to HEX List

2006-07-31 Thread John Machin
Philippe Martin wrote: John Machin wrote: So why don't you get a freely available bignum package, throw away the bits you don' t want, and just compile it and use it, instead of writing your own bug-ridden (see below) routines? Oh yeah, the bignum package might use long and you think

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote: Have you actually tried it? Do you mean it barfs on the word long [meaning that it's not an ANSI-compliant C compiler], or that long is only 16 bits? :-) if the documentation tells me there is no 32 bit support, why should I not believe it ? because (1) [like I said

Re: BCD List to HEX List

2006-07-31 Thread John Machin
Philippe Martin wrote: Sorry forgot a few answers/comments: John Machin wrote: SHOULD BE = currently add([6, 6], [4, 4] - [10, 10] True, thanks *** try - 10 instead of % 10 If the first operand is 19, you have a bug! This might save a few CPU cycles on your smartcard can it

Re: BCD List to HEX List

2006-07-31 Thread Simon Forman
Philippe, please! The suspense is killing me. What's the cpu!? For the love of God, what's the CPU? I-can't-take-it-anymore-it's-such-a-simple-question-ingly yours, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: BCD List to HEX List

2006-07-31 Thread John Machin
Simon Forman wrote: Philippe, please! The suspense is killing me. What's the cpu!? For the love of God, what's the CPU? I-can't-take-it-anymore-it's-such-a-simple-question-ingly yours, Yes, please . I've found a C compiler manual on the web for the Epson S1C33 CPU as well as the one

Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote: Simon Forman wrote: Philippe, please! The suspense is killing me. What's the cpu!? For the love of God, what's the CPU? I-can't-take-it-anymore-it's-such-a-simple-question-ingly yours, Yes, please . I've found a C compiler manual on the web for the Epson

Re: BCD List to HEX List

2006-07-31 Thread Grant Edwards
On 2006-08-01, Philippe Martin [EMAIL PROTECTED] wrote: Perhaps if Philippe could divulge the part number that's in the bottom right corner of the manual that he has, and/or any part number that might be mentioned in the first few pages of that manual, enlightenment may ensue That was

Re: BCD List to HEX List

2006-07-31 Thread John Machin
Grant Edwards wrote: On 2006-08-01, Philippe Martin [EMAIL PROTECTED] wrote: Perhaps if Philippe could divulge the part number that's in the bottom right corner of the manual that he has, and/or any part number that might be mentioned in the first few pages of that manual, enlightenment

Re: BCD List to HEX List

2006-07-31 Thread bryanjugglercryptographer
John Machin wrote: [EMAIL PROTECTED] wrote: Philippe Martin wrote: Yes, I came here for the algorithm question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Yeah yeah

BCD List to HEX List

2006-07-30 Thread Philippe Martin
Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678 l2 = func (l1) # l2 =

Re: BCD List to HEX List

2006-07-30 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Philippe Martin wrote: I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Philippe Martin wrote: I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library.

Re: BCD List to HEX List

2006-07-30 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Philippe Martin wrote: Marc 'BlackJack' Rintsch wrote: And now please describe you problem a little better. ;-) I'll try. first of all python is not going to be used for my purpose (sigh) I have device A which holds a binary coded decimal array [N1,N2,Nn]

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Philippe Martin wrote: Marc 'BlackJack' Rintsch wrote: And now please describe you problem a little better. ;-) I'll try. first of all python is not going to be used for my purpose (sigh) I have device A which holds a binary

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: Such as what? I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents the

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: Such as what? I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 =

Re: BCD List to HEX List

2006-07-30 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678 This is untested, but should give you

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678 This is

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: Such as what? I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: Such as what? I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Dennis Lee Bieber wrote: On Sun, 30 Jul 2006 16:39:47 -0500, Philippe Martin [EMAIL PROTECTED] declaimed the following in comp.lang.python: My apologies, I clearly made a mistake with my calculator, yes the resulting array I would need is [0xb,0xc,0x6,0x1,0x4,0xe] Take note that this is

Re: BCD List to HEX List

2006-07-30 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: I'm just using Python to prototype, so I cannot use any of these great features of the language. I think when writing a prototype, you should use whatever features you want, except maybe at the upper levels of program organization. The idea of

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Paul Rubin wrote: Philippe Martin [EMAIL PROTECTED] writes: I'm just using Python to prototype, so I cannot use any of these great features of the language. I think when writing a prototype, you should use whatever features you want, except maybe at the upper levels of program

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: Thanks John, I do not have a long available on the device: stuck with 16 bits. What does available on the device mean? Having a long is a property of a C complier, not a device. What is the CPU in the device? What is the C compiler you are using? N.B. Last time I

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: Thanks John, I do not have a long available on the device: stuck with 16 bits. What does available on the device mean? Having a long is a property of a C complier, not a device. What is the CPU in the device? What is the C compiler you are

Re: BCD List to HEX List

2006-07-30 Thread Paul Rubin
Philippe Martin [EMAIL PROTECTED] writes: Thanks John, I do not have a long available on the device: stuck with 16 bits. Oh, I think I understand now, why you were asking about algorithms. You really did want something whose intermediate results all fit in 16 bits. Even if your C compiler

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8] #represents the decimal

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: Thanks John, I do not have a long available on the device: stuck with 16 bits. What does available on the device mean? Having a long is a property of a C complier, not a device. What is the CPU in the device?

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Have you considered asking on a newsgroup where your problem might actually be on-topic, like: comp.lang.c Yes, I came here for the algorithm question, not the code result. Regards, Philippe -- http://mail.python.org/mailman/listinfo/python-list

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = [1,2,3,4,6,7,8]

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: John Machin wrote: Have you considered asking on a newsgroup where your problem might actually be on-topic, like: comp.lang.c Yes, I came here for the algorithm question, not the code result. This is comp.lang.python, not comp.algorithms Why are you

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library.

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: John Machin wrote: Have you considered asking on a newsgroup where your problem might actually be on-topic, like: comp.lang.c Yes, I came here for the algorithm question, not the code result. This is comp.lang.python, not

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: John Machin wrote: Have you considered asking on a newsgroup where your problem might actually be on-topic, like: comp.lang.c Yes, I came here for the algorithm question, not the code result. This is

Re: BCD List to HEX List

2006-07-30 Thread Grant Edwards
On 2006-07-30, John Machin [EMAIL PROTECTED] wrote: Yes, I came here for the algorithm question, not the code result. This is comp.lang.python, not comp.algorithms Why are you avoiding naming the chip and its compiler? It's top secret. If he told us, he'd have to kill us. -- Grant

Re: BCD List to HEX List

2006-07-30 Thread Grant Edwards
On 2006-07-31, John Machin [EMAIL PROTECTED] wrote: but if you wish == on one device, the processor in an 8-bit arm and the X-compiler is made by epson 1. You still haven't *NAMED* the CPU and the compiler!! He obviously doesn't want to have to kill all of us. 2. Do you mean ARM as in

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Dennis Lee Bieber wrote: On Sun, 30 Jul 2006 17:07:57 -0500, Philippe Martin [EMAIL PROTECTED] declaimed the following in comp.lang.python: Paul Rubin wrote: If you prefer, You can do it all in one line: vlist = [int(d, 16) for d in ('%X' % int(''.join(map(str, l1]

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Grant Edwards wrote: On 2006-07-31, John Machin [EMAIL PROTECTED] wrote: but if you wish == on one device, the processor in an 8-bit arm and the X-compiler is made by epson 1. You still haven't *NAMED* the CPU and the compiler!! He obviously doesn't want to have to kill all of us.

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Philippe Martin wrote: Grant Edwards wrote: On 2006-07-31, John Machin [EMAIL PROTECTED] wrote: but if you wish == on one device, the processor in an 8-bit arm and the X-compiler is made by epson 1. You still haven't *NAMED* the CPU and the compiler!! He obviously doesn't want to

Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote: Philippe Martin wrote: John Machin wrote: Philippe Martin wrote: Philippe Martin wrote: Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: 3. How does the device manage to compute the 8-decimal-digit number that is your input?? What device manager ? think about it before being rude No device manager [noun] was mentioned. You may have inferred rudeness where astonishment was being implied. I'll try

Re: BCD List to HEX List

2006-07-30 Thread John Machin
Philippe Martin wrote: Yes I had arm in mind (for some reason) while it is the Smc8831 (http://www.google.com/url?sa=Ustart=1q=http://www.epsondevice.com/www/PDFS/epdoc_ic.nsf/5388db40b5eee4f949256a9c001d589f/944b73008b0bad33492570a00015d6ba/%24FILE/S5U1C88000C_2Ev3.pdfe=9797) That appears to