Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › questions: 1)Logarithm and 2)length of int array[]

Page Index Toggle Pages: 1
questions: 1)Logarithm and 2)length of int array[] (Read 4186 times)
05/11/08 at 16:51:28

lordrivera   Offline
YaBB Newbies
I Love YaBB 2!
los angeles

Posts: 6
*
 
I am using an arduino to control a truckload of LEDs. I searched around and couldnt see if there was any way to perform a logarithm math function (with a specific base) in the wiring language. Does anyone know how I might do this? Is there a library I can add? If so can anyone tell me how to do it?


also i want to know the maximum lenth of elements in an int array[]
I mean when I define an array whats the maximum amount of elements I can declare in an array like so:
int register[] {
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,......}

I know that "int" spans from +32,767 to -32,768, but how does that translate to the above?


Thanks!
 
IP Logged
 
Reply #1 - 05/11/08 at 17:30:00

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
I think the issue to consider is the amount of memory an array requires, Arduino has 8K (atmega8 version) and 16K (atmega168 version). Wiring has 128K. So it is good to calculate the right amount of memory for what you're doing. An integer takes 16 bits of memory (2 bytes) so multiplying by the number of elements you'll have the size you're looking for. Check this too: http://wiring.org.co/learning/reference/unsignedint.html
 
IP Logged
 
Reply #2 - 05/12/08 at 00:51:43

lordrivera   Offline
YaBB Newbies
I Love YaBB 2!
los angeles

Posts: 6
*
 
Oh Right! Each element in the array is a new int variable! I forgot.

to save space, I can use a byte, correct?

is there a list of all of the memory sizes of the primatives?

thanks!

any ideas about logarithm, or natural log?
 
IP Logged
 
Reply #3 - 05/12/08 at 15:35:36

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Yes byte will take less space, all math C/C++ funcitons are available in the wiring environment with no need to add any include in the code. Here is an online manual for the avrlibc math library http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html and here is the reference for the datatypes as well http://wiring.org.co/learning/reference/index.html
 
IP Logged
 
Page Index Toggle Pages: 1