Re: Limiting a float
Re: Limiting a float
- Subject: Re: Limiting a float
- From: publiclook <email@hidden>
- Date: Wed, 27 Aug 2003 19:51:37 -0400
If you only want to limit the display and/or input of digits, assign a
formatter to the text field. See NSFormatter class and the formatters
on a palette in Interface Builder.
If you want to actually truncate a float value to a certain number of
digits, see past threads in this forum. There is a search interface at
http://cocoa.mamasam.com/. Look at standard C functions like floor().
OR you can create a string representation of your float value as
follows and set the string value of the output field.
[NSString stringWithFormat:@"%0.2f", someFloayValue];
There are of course many tutorials and examples for this type of
ultra-beginning thing (start at Apple and www.stepwise.com, as well as
many nice books available to augment Apple's generally good
documentation.
On Wednesday, August 27, 2003, at 07:05 PM, Emig 647 wrote:
I am beginning cocoa ... Again.
For my first app I made a conversion between Kelvin, Celsius,
Fahrenheit.
I send the result to an NSTextField as a float...
The problem is the float is sent as 17.340209972309 and I want to
limit it
to 2 places to the right of the decimal...
Any ideas?
- Cody
_______________________________________________
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.
_______________________________________________
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.