discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining float values from Array


From: Fred Kiefer
Subject: Re: Obtaining float values from Array
Date: Sat, 05 Feb 2011 20:29:02 +0100

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 <jbatarina@gmail.com>
> An: discuss-gnustep <discuss-gnustep@gnu.org>
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]