Re: NSNumber stringValue

2009-12-15 Thread Lane Roathe
on Sat, Dec 12, 2009 Andy Lee may have said: >As glenn pointed out, that string most certainly *can* be a string that >can be converted back to a bitwise equivalent of the original float. >Ben's question was whether in practice it is guaranteed to be so, or >whether stringValue uses a maximum numb

Re: NSNumber stringValue

2009-12-12 Thread Andy Lee
On Dec 12, 2009, at 7:38 PM, RedleX Support wrote: > My original intent was to store a representation of the float in a string so > I can load it back again. In the meanwhile I found that using the %a format > along with NSScanner's scanHexDouble does the trick (since I don't need that > string

Re: NSNumber stringValue

2009-12-12 Thread RedleX Support
You should not compare floating point numbers for equality in most cases. This is true of any language on any platform. Indeed, some floating-point numbers (such as the one represented by the integer 0x7fc0) will compare as not equal to themselves: I think what the OP really wanted to

Re: NSNumber stringValue

2009-12-12 Thread Andrew Farmer
On 12 Dec 2009, at 09:32, Ben Haller wrote: >>> You should not compare floating point numbers for equality in most cases. >>> This is true of any language on any platform. >> >> Indeed, some floating-point numbers (such as the one represented by the >> integer 0x7fc0) will compare as not equ

Re: NSNumber stringValue

2009-12-12 Thread Andy Lee
P.P.S. Never mind, passing f = 0.12345678901234567 is a counterexample. So the answer is no, you won't get a bitwise equivalent if you do a stringValue-floatValue round trip. --Andy On Dec 12, 2009, at 1:25 PM, Andy Lee wrote: > On Dec 12, 2009, at 1:07 PM, Andy Lee wrote: >> If I understand

Re: NSNumber stringValue

2009-12-12 Thread Andy Lee
On Dec 12, 2009, at 1:07 PM, Andy Lee wrote: > If I understand the question, it's not about converting an arbitrary decimal > string to a float, but specifically a string that was generated from a float > in the first place. > > As glenn pointed out, that string most certainly *can* be a string

Re: NSNumber stringValue

2009-12-12 Thread Andy Lee
On Dec 12, 2009, at 12:51 PM, David Rowland wrote: > On Dec 12, 2009, at 9:32 AM, Ben Haller wrote: > You should not compare floating point numbers for equality in most cases. This is true of any language on any platform. >>> >>> Indeed, some floating-point numbers (such as the one rep

Re: NSNumber stringValue

2009-12-12 Thread David Rowland
On Dec 12, 2009, at 9:32 AM, Ben Haller wrote: You should not compare floating point numbers for equality in most cases. This is true of any language on any platform. Indeed, some floating-point numbers (such as the one represented by the integer 0x7fc0) will compare as not equal to th

Re: NSNumber stringValue

2009-12-12 Thread glenn andreas
On Saturday, December 12, 2009, at 11:32AM, "Ben Haller" wrote: >>> You should not compare floating point numbers for equality in most >>> cases. This is true of any language on any platform. >> >> Indeed, some floating-point numbers (such as the one represented by >> the integer 0x7fc0

Re: NSNumber stringValue

2009-12-12 Thread Ben Haller
You should not compare floating point numbers for equality in most cases. This is true of any language on any platform. Indeed, some floating-point numbers (such as the one represented by the integer 0x7fc0) will compare as not equal to themselves: I think what the OP really wanted to

Re: NSNumber stringValue

2009-12-11 Thread Andrew Farmer
On 11 Dec 2009, at 21:14, Bryan Henry wrote: > You should not compare floating point numbers for equality in most cases. > This is true of any language on any platform. Indeed, some floating-point numbers (such as the one represented by the integer 0x7fc0) will compare as not equal to themse

Re: NSNumber stringValue

2009-12-11 Thread Bryan Henry
Hi, > > I need to output a double into a text file and then read it back with 100% > accuracy, will using NSNumber stringValue and then using NSString doubleValue > give me good results? > > For example, if I write the following: > > double a,b; > >

NSNumber stringValue

2009-12-11 Thread RedleX Support
Hi, I need to output a double into a text file and then read it back with 100% accuracy, will using NSNumber stringValue and then using NSString doubleValue give me good results? For example, if I write the following: double a,b; a=some number; b=[[[NSNumber numberWithDouble:a