DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Thread: Decimal

  1. #1
    Dean Guest

    Decimal


    What would be the coding to specify floats to be to 2 decimal places??

  2. #2
    Yuri Guest

    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??



  3. #3
    Dean Guest

    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??

    >



  4. #4
    Yuri Guest

    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??

    >>

    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links