Re: Double Fun
Re: Double Fun
- Subject: Re: Double Fun
- From: Jed Soane <email@hidden>
- Date: Tue, 7 Feb 2006 11:03:27 +1300
Works for me:
double totalSellPrice, xtnSell, pct;
totalSellPrice = 3888.407600;
NSLog(@"sellPrice = %f", totalSellPrice);
if ( totalSellPrice != 0 ) {
xtnSell = 84.018060;
NSLog(@"ExtndSell = %f",xtnSell);
pct = (xtnSell/ totalSellPrice) * 100.00;
NSLog(@"Percent = %f",pct);
}
2006-02-07 10:55:04.236 doubleTest[5498] sellPrice = 3888.407600
2006-02-07 10:55:04.237 doubleTest[5498] ExtndSell = 84.018060
2006-02-07 10:55:04.237 doubleTest[5498] Percent = 2.160732
Are you using a new Intel Mac? Maybe there's a floating point bug ;)
I don't why it's not working for you. Maybe take a look at the
original values to see if they are what you expect:
NSLog(@"sell price = %@, extnd price = %@", [self totalSellingPrice],
[self extendedSellingPrice]);
Jed
On Feb 7, 2006, at 10:19 AM, Steve Cronin wrote:
Folks;
Could some merciful person take away my misery here:
double totalSellPrice, xtnSell, pct;
totalSellPrice = [[self totalSellingPrice] doubleValue];
NSLog(@"sellPrice = %f", totalSellPrice);
if ( totalSellPrice != 0 ) {
xtnSell = [[self extendedSellingPrice] doubleValue];
NSLog(@"ExtndSell = %f",xtnSell);
pct = (xtnSell/ totalSellPrice) * 100.00;
NSLog(@"Percent = %f",pct);
...
Results in these log entries:
2006-02-06 15:05:11.110 ABC[18600] sellPrice = 3888.407600
2006-02-06 15:05:11.110 ABC[18600] ExtndSell = 84.018060
2006-02-06 15:05:11.110 ABC[18600] Percent = 300.0000
Thanks!
Steve
_______________________________________________
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
_______________________________________________
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
References: | |
| >Double Fun (From: Steve Cronin <email@hidden>) |