The very last section of Numerical Recipes in C is devoted to arbitrary precision arithmetic. Their code is based on stuff Knuth wrote and = other libraries that they provide. An on-line version of the book can be = found at http://www.nr.com. You should be able to look at their code a simplify it for the 24-bit = functions that you care about. If you want to carry less baggage, but do more of your own coding, I = have a library for arbitrary length arrays of bits at: http://michael.dipperstein.com/bitlibs/ It includes Increment, Decrement, Shift, And, Or, Xor, and Not = functions. I keep thinking about extending it to include more arithmetic functions. = I have yet to do it, but your welcome to have a go at it. The code size could be greatly reduced if only 24-bit arrays were = supported. -Mike -----Original Message----- From: pic microcontroller discussion list = [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Andre Miller Sent: Thursday, April 01, 2004 4:09 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC:] Microchip C18, or HI-TECH PICC18? =20 That's a great idea. Do you perhaps have some sample code to = demonstrate this? It will be much appreciated :-) Say for example I want a 24 bit signed variable, using a struct for = storage, how would I: Decrement that value Compare it in an 'if' statement? I can see how I would do it using a pointer to the struct, but wouldn't = the storage for the pointer negate the space saved by using a 3 byte = struct? Sorry if this is a stupid question, I know C (or I think I do), but are relatively new to PIC's and the need to save as much RAM as possible. = Using C on a PC with 512MB of RAM this is less of an issue ;-). _____ =20 Andr=E9 Miller =09 -----Original Message----- From: pic microcontroller discussion list = [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Gerhard Fiedler Sent: 01 April 2004 01:33 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC:] Microchip C18, or HI-TECH PICC18? >>Have you ever found you needed a 24 bit integer datatype and wished >>PICC had support for it? > > Frequently. There are many cases where 16 bits isn't quite enough but = > 32 is wasteful. > Probably less of an issue on the PIC18, but on the 16 series, RAM is > usually the first thing you run out of. For me that's "sometimes". In those cases I use 3 byte structs for = storage and the built-in 32 bit routines for the calculations. I've never had a = case where the additional resources that were needed to do the 32 bit calculations = (temp register, instruction cycles) were a problem. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads