RE: Round a float
RE: Round a float
- Subject: RE: Round a float
- From: Oliver Donald <email@hidden>
- Date: Tue, 29 Jul 2003 09:34:23 +0100
To round your float DOWN to 1 decimal place, just do:
printf("floatSize = %0.1f", floatSize - 0.5);
-----Original Message-----
From: Steve Bird [
mailto:email@hidden]
Sent: Monday, July 28, 2003 6:42 PM
To: Lorenzo
Cc: email@hidden
Subject: Re: Round a float
On Monday, July 28, 2003, at 09:41 AM, Lorenzo wrote:
>
Hi,
>
I have a
>
float floatSize = 105.55791;
>
and I would like to print it as @"105.5";
--- Everybody has said to use %0.1f, but notice that that function will
ROUND the number you gave UP to "105.6". If you really DO want to see
"105.5", you'll have to do the truncation yourself.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
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.
DISCLAIMER: The information contained in this e-mail is confidential and may
be privileged. It is intended for the addressee only. If you are not the
intended recipient, please delete this e-mail immediately.
The contents of this email must not be disclosed or copied without the
sender's consent. We cannot accept any responsibility for viruses, so please
scan all attachments.
The statements and opinions expressed in this message are those of the
author and do not necessarily reflect those of the company. The company does
not take any responsibility for the views of the author.
_______________________________________________
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.