
Home  Forums  Rules  Articles  diyAudio Store  Gallery  Wiki  Blogs  Register  Donations  FAQ  Calendar  Search  Today's Posts  Mark Forums Read  Search 
Everything Else Anything related to audio / video / electronics etc) BUT remember we have many new forums where your thread may now fit! .... Parts, Equipment & Tools, Construction Tips, Software Tools...... 

Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving 

Thread Tools  Search this Thread 
16th June 2010, 02:59 PM  #1 
diyAudio Member
Join Date: Sep 2005

32 bit operations: long vs. float
Quick question for the digital people:
If I have a 32 bit microcontroller (say, a PIC32), and I add two "long" variables together, will that take the same amount of time (processor cycles) as adding two "float" variables together (since they are both 32 bit numbers)? What about the same question above, except with multiplication/division? 
16th June 2010, 04:18 PM  #2 
diyAudio Member
Join Date: Feb 2003
Location: ..

assuming at best integer multiplier accumulator
adding floats takes longer since the mantissas have to be aligned to the same exponent by shifting multiplication only takes a few more ops since you multiply mantissas and add exponents both have overhead in "unpacking" exponent from mantissa in floating point do everything in your power to rearrange the math so you avoid division there are chips with floating point "engines"  usually the manufacturer is very vocal about offering floating point hardware: if you don't see it in the features/datasheet bullet items then you likely have integer ALU/MAC Last edited by jcx; 16th June 2010 at 04:35 PM. 
16th June 2010, 04:41 PM  #3  
diyAudio Member
Join Date: Apr 2010
Location: Evanston, IL

Quote:
In terms of performance, one exception to this rule is if you are using a microprocessor that is specifically built to process floating point data, and even in this case, floating point operations will generally only equal the performance of integer operations, and will not exceed. Float versus Integer arithmetic performance on modern chips  Stack Overflow Please note that what I say is only a general principle that I know  I have not worked with microcontrollers enough to give you a definitive answer. 

16th June 2010, 05:02 PM  #4  
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

Quote:
Why not put both Int and FP operations into a very simple program, compile it, and run it in the MPSIM simulator? You can get cycleaccurate timings that way and then you'll see your answer right there in front of you. This is also a great way to see the impact of different optimization switches. 

16th June 2010, 09:56 PM  #5 
diyAudio Member
Join Date: Aug 2008

You can always use integers in place of floating point by changing the units.
Also, multiplication and division by powers of 2 (2, 4, 8, 16...) is very fast, because it's just a bit shift.
__________________
Tyler 
17th June 2010, 12:24 PM  #6 
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

I need to correct myself, the PIC32 does have int divide instructions, both signed and unsigned. I was thinking of the PIC24 that has divide assistance.

23rd June 2010, 09:20 PM  #7 
diyAudio Member
Join Date: Nov 2006

so what programming language and compiler you are using. can't think straight right now but generally if you have 32bit processor it takes twice as long to calculate two 32bit vectors than two 16bit long vectors. Bit wide of float, douple... and others differ between programming language.

27th June 2010, 02:04 PM  #8  
diyAudio Member

Quote:
What Every Computer Scientist Should Know About Floating Point  Computational Science and Engineering 

Thread Tools  Search this Thread 


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Anyone hear this 32 bit/192Khz source ?  ashok  Digital Source  2  25th October 2009 06:00 AM 
Cooledit/Audition 32 bit not IEEE754?  scott wurcer  Digital Line Level  6  18th July 2009 12:15 AM 
32bit DAC  jan.didden  Digital Source  54  14th March 2008 09:07 PM 
32 bit DAC?  stelleg151  Digital Source  8  30th April 2006 08:23 PM 
32bit mono on CDA  Circlotron  Digital Source  0  17th February 2003 12:39 AM 
New To Site?  Need Help? 