Re: NSLog with %f and comparisons using ==

2009-04-12 Thread Ken Thomases
Chiming in late-ish... On Apr 11, 2009, at 12:26 PM, James Maxwell wrote: oooh, damn... I was afraid someone was going to say that. I just hoped there might be some way to force a float to conform to what NSLog %f prints... That seems like it might be a useful function - something like pro

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 7:47 PM, James Maxwell wrote: > oh, geez... Okay, you guys made your point! ;-) > > One thing I love about this list; I *always* get useful info. > > I'll find a better way to do this soon. In this particular case, the "match" > could be specified as broadly as any value fa

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
oh, geez... Okay, you guys made your point! ;-) One thing I love about this list; I *always* get useful info. I'll find a better way to do this soon. In this particular case, the "match" could be specified as broadly as any value falling within a sort of "bin." The "bottoms" of each of these

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 4:45 PM, James Maxwell wrote: > hmm... Well, this all sounds like a sledge-hammer approach to my immediate > problem. > > The actual explanation of what I'm doing is kind of long-winded, so I'll > spare you that. For now, I know the calculated values will always come out >

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
hmm... Well, this all sounds like a sledge-hammer approach to my immediate problem. The actual explanation of what I'm doing is kind of long-winded, so I'll spare you that. For now, I know the calculated values will always come out the same, since there are a limited number of possible in

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Guerin
James Maxwell wrote: Now, when I run the calculation "live" and try to compare to my stored constants, I'm not getting matches. I'm assuming this is because the result of the calculation *isn't* actually what I stored in my constants, since the constants were rounded during the NSLog. So,

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Guerin
James Maxwell wrote: Yeah, that's an idea... But I do need it to be fairly efficient. I've solved the problem by calculating fabs(val1 - val2) and only allowing a very small margin of error (0.01). It seems to be working. If this is still going to be disaster-prone, I'd appreciate a qu

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
Yeah, that's an idea... But I do need it to be fairly efficient. I've solved the problem by calculating fabs(val1 - val2) and only allowing a very small margin of error (0.01). It seems to be working. If this is still going to be disaster-prone, I'd appreciate a quick heads-up. But keep

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Titus
If what you really want is to see whether the result is the same as %f previously printed, then you could always make your array of constants an array of constant _strings_ and then compare the strings. Not terribly efficient, maybe, but straightforward. - Greg On Apr 11, 2009, at

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
oooh, damn... I was afraid someone was going to say that. I just hoped there might be some way to force a float to conform to what NSLog %f prints... That seems like it might be a useful function - something like pround(aFloat), for "print-round", to force any float number to round as the p

Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 12:46 PM, James Maxwell wrote: > I've got a strange problem. > I have a list of float constants that I need to compare to the result of a > new calculation. > > I derived the constants by performing the calculation, and printing using > NSLog with %f, then just writing down

NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
I've got a strange problem. I have a list of float constants that I need to compare to the result of a new calculation. I derived the constants by performing the calculation, and printing using NSLog with %f, then just writing down the results in my array of constants. So, the result of th