CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

64 bit math

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kuriken



Joined: 21 Oct 2006
Posts: 19

View user's profile Send private message

64 bit math
PostPosted: Wed Mar 30, 2011 3:20 pm     Reply with quote

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: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 3:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 3:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 3:46 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 10, 2012 12:01 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Tue Jan 10, 2012 2:50 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Tue Jan 10, 2012 6:24 pm     Reply with quote

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 Crying or Very sad

Very Happy Smile Question
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group