Re: NSTextField setFloatValue broken?
Re: NSTextField setFloatValue broken?
- Subject: Re: NSTextField setFloatValue broken?
- From: Pierre-Olivier Latour <email@hidden>
- Date: Fri, 06 Sep 2002 13:18:13 +0200
>
If you want the values formatted a particular way, the best way is to
>
use an NSFormatter. Why is this a problem?
Well, it simpler to use than passing through an NSNumberFormatter which are
buggy anyway when asking for localization (thousand separators do not work
correctly in 10.2 on non-US systems).
Furthermore, using setFloatValue had the advantage over a formatter to have
a variable number of digits: 0.5 would be displayed as 0.5, not as 0.500,
and 0.501 would be displayed as 0.501. With an NSNumberFormatter the number
of fractional digits is fixed.
>
> Another side effect is that if you enter a value in the text field,
>
> get it
>
> with floatValue, then redisplay it, you do not see the value your
>
> entered
>
> but very often a number with 10 or so decimal digits!
>
>
It's not a bug. Not all decimal values can be represented exactly as
>
floating point values. This is just a fundamental issue with the
>
machine's representation of floating point numbers, and doesn't have
>
anything to do with Cocoa specifically.
I know about representation problem of floating point number, but here, this
is not the point.
When the user enters 0.5 in a text field, and then when he re-edits the
value, he sees 0.499999990007 or whatever, when the problem was not here in
10.1, I call this an interface bug.
Right now setDoubleValue, doubleValue, setFloatValue and floatValue seem to
be useless on NSTextFields.
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland
http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.