Depends on what is in the array. If we are talking about NSNumber objects here
it is fairly easy.
sumOfArray += [[storage objectAtIndex: x] floatValue];
Hope this helps
Fred
-------- Original-Nachricht --------
> Datum: Sun, 6 Feb 2011 02:03:58 +0800
> Von: Jeric Batarina <[email protected]>
> An: discuss-gnustep <[email protected]>
> Betreff: Obtaining float values from Array
> I want to get the average of the numbers in my array. So how can I get
> those
> values and turn them back into floats??
>
> Code(I'm not sure if I used the right ones):
>
> ....
>
> for(x=0;x<=[storage count];x++){
> sumOfArray= sumOfArray+[NSNumber [storage objectAtIndex:x]];
> //Problem here. I'm trying to get the float values in the Array.
> }
>
> averageOfArray=sumOfArray/[storage count];
> printf("Average: %f",averageOfArray);
> break;
--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep