View previous topic :: View next topic |
Author |
Message |
kuriken
Joined: 21 Oct 2006 Posts: 19
|
64 bit math |
Posted: Wed Mar 30, 2011 3:20 pm |
|
|
Hi,
I need to perform 32 bit multiplications and 64 bit addition and subtractions. I realize that CCS does not support int64. I also found the following discussion on this forum that provides a way to create a unsigned 64 type.
http://www.ccsinfo.com/forum/viewtopic.php?p=72037
Unfortunately I need a signed 64 (long long in ANSI C) to port over a code library created using ANSI C. Has anybody come across sample code on how I might be able to do this?
Thanks,
Ken |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Mar 30, 2011 3:26 pm |
|
|
I have to ask the obvious, why are you asking a poor little PIC to do that kind of math. Just seems 'wrong'. |
|
|
kuriken
Joined: 21 Oct 2006 Posts: 19
|
|
Posted: Wed Mar 30, 2011 3:32 pm |
|
|
My previous project used a PIC18 and I'm just adding one more feature to it. It would be convenient for me if I could use the same platform. I'm contemplating jumping over to a ATMEL chip or using a PIC24 but I would like to avoid it if I can. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Mar 30, 2011 3:46 pm |
|
|
Are there any quantities in the universe that are known to 64 bit accuracy? That is 18 x 10^18, or roughly 10,000 x the number of grains of sand in the Hoover dam! What would a lowly micro controller do with such a number?
Try calculating how big the 32x32 bit multiplication could actually get, given realistic inputs. I bet you don't really need 64 bit math. I designed a product that measures ships in 24 bit millimeters. It can handle any ship ever designed. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
PICman
Joined: 02 Nov 2007 Posts: 26
|
|
Posted: Tue Jan 10, 2012 12:01 pm |
|
|
SherpaDoug wrote: | Are there any quantities in the universe that are known to 64 bit accuracy? That is 18 x 10^18, or roughly 10,000 x the number of grains of sand in the Hoover dam! What would a lowly micro controller do with such a number?
Try calculating how big the 32x32 bit multiplication could actually get, given realistic inputs. I bet you don't really need 64 bit math. I designed a product that measures ships in 24 bit millimeters. It can handle any ship ever designed. |
Simple: Public key cryptography WILL require int64 and even way higher precision INT math. _________________ The ideal electronic world: A place where the words VERSION and REVISION do NOT exist ! |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Tue Jan 10, 2012 2:50 pm |
|
|
Well, all operations involving integer math can be done in base 2 (binary)notation.
All that is required is storage space for the notation. If its 64 bits then then less than 100 bytes of storage would be needed to contain the binary notation and arithmetic operations when carried out to two to the power 64.
The issue is convenience and speed. CCS's compiler provides routines to manipulate this notation in 8bit 16bit and 32bit chunks ( using standard operators). Now a typical hand held calculator does this in 4 bit binary coded decimal and handles decimal notation to the number of digits its lcd can show (often 10 or more digits). It is true it is easier to handle the carry with a 32bit MCU register and it may take fewer instructions but an 8bit PIC with several hundred bytes of storage could perform 500 bit binary notation arithmetic. The choice is speed and convenience. As said in an earlier post with the exception of pure mathematics ( like in cryptography) there is no need for accuracy beyond the 12 digit decimal precision of that of quantum mechanics (our most accurate physical law todate)...2 to the power 64 or say 20 decimal digits is overkill for the real world we live in. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jan 10, 2012 6:24 pm |
|
|
i gotta say - there are times that integrated
24 bit math routines would be a MIGHTY Useful to me ;-))
i'm thinking here of a customer, project
i'm looking at, using the ADS 1225 with precision load cells
and 24 bit integrated 24 bit functions would be very very sweet
for now - its all about stuffing it into an int32
|
|
|
|