-
Decimal
What would be the coding to specify floats to be to 2 decimal places??
-
Re: Decimal
Dean,
float occupies 4 bytes and it's storage depends on platform,
you can only specify conversion of float to string with desirable format.
"Dean" <dbruce11@yahoo.com> wrote:
>
>What would be the coding to specify floats to be to 2 decimal places??
-
Re: Decimal
Yeah, but I tried to use setprecision and I tried to use printf but neither
works properly. Do you know the actual coding as to how to specify just
2 decimal places?
"Yuri" <putivsky@home.com> wrote:
>
>Dean,
>float occupies 4 bytes and it's storage depends on platform,
>you can only specify conversion of float to string with desirable format.
>
>
>"Dean" <dbruce11@yahoo.com> wrote:
>>
>>What would be the coding to specify floats to be to 2 decimal places??
>
-
Re: Decimal
Try
float ft;
// assign ft here;
char buffer[32];
sprintf(buffer, "%#10.2f", ft);
"Dean" <dbruce11@yahoo.com> wrote:
>
>Yeah, but I tried to use setprecision and I tried to use printf but neither
>works properly. Do you know the actual coding as to how to specify just
>2 decimal places?
>
>"Yuri" <putivsky@home.com> wrote:
>>
>>Dean,
>>float occupies 4 bytes and it's storage depends on platform,
>>you can only specify conversion of float to string with desirable format.
>>
>>
>>"Dean" <dbruce11@yahoo.com> wrote:
>>>
>>>What would be the coding to specify floats to be to 2 decimal places??
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks