• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
What's wrong with this code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's wrong with this code?


  • Subject: What's wrong with this code?
  • From: Ayyapu Reddy <email@hidden>
  • Date: Thu, 25 Nov 2004 14:14:01 +0530

Hi All,

What's wrong with this code?
numbers is the array of float values (NSNumber objects).
If i print the return value of this function, it prints Sum
-1600107392.000000

Here is the log statement NSLog(@"Sum %f",
sumOfNumbers);

float
sumOfNumbers(NSArray *numbers){
int i, count = [numbers count];
float sum = 0.0;
for(i = 0; i<count; i++){
sum = sum + [[numbers objectAtIndex:i] floatValue];
}
return sum;
}

Can anybody please let me know the mystery behind this?

Thanks in advance.
Ayyapu Reddy


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: What's wrong with this code?
      • From: 陳銘崧 a.k.a. James Chen <email@hidden>
    • Re: What's wrong with this code?
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Unicode case conversion
  • Next by Date: NSDocument notification
  • Previous by thread: Re: Excelsior for XML marshling and demarshling
  • Next by thread: Re: What's wrong with this code?
  • Index(es):
    • Date
    • Thread