Wiring Forum http://wiring.org.co/cgi-bin/yabb/YaBB.pl Programming Questions & Help >> Syntax >> questions: 1)Logarithm and 2)length of int array[] http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1210524688 Message started by lordrivera on 05/11/08 at 16:51:28

 Title: questions: 1)Logarithm and 2)length of int array[] Post by lordrivera on 05/11/08 at 16:51:28 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!

 Title: Re: questions: 1)Logarithm and 2)length of int arr Post by barragan on 05/11/08 at 17:30:00 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

 Title: Re: questions: 1)Logarithm and 2)length of int arr Post by lordrivera on 05/12/08 at 00:51:43 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?

 Title: Re: questions: 1)Logarithm and 2)length of int arr Post by barragan on 05/12/08 at 15:35:36 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