DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: float in 2 decimal point

  1. #1
    hoon Guest

    float in 2 decimal point


    i have a problem displaying a control's member variable of type float in two
    decimal place.
    do anyone of u know how?
    tq

  2. #2
    Danny Kalev Guest

    Re: float in 2 decimal point

    you can use the setprecision function if you're using iostreams. If
    you're using printf(), you need to use an appropriate string format:
    %2.2f.

    Danny Kalev

    http://www.amazon.com/exec/obidos/ASIN/0789720221
    Please reply to the newsgroup.

    hoon wrote:
    >
    > i have a problem displaying a control's member variable of type float in two
    > decimal place.
    > do anyone of u know how?
    > tq


  3. #3
    hoon Guest

    Re: float in 2 decimal point


    actually i'm using visual c++. and the problem here is, this is a control's
    member variable where the value assign to it will get display automatically
    when u call UpdateData. so i want to display the variable of type float in
    two decimal point when UpdateData is call. do u know how?
    tq.

    Danny Kalev <dannykk@inter.net.il> wrote:
    >you can use the setprecision function if you're using iostreams. If
    >you're using printf(), you need to use an appropriate string format:
    >%2.2f.
    >
    >Danny Kalev
    >
    >http://www.amazon.com/exec/obidos/ASIN/0789720221
    >Please reply to the newsgroup.
    >
    >hoon wrote:
    >>
    >> i have a problem displaying a control's member variable of type float

    in two
    >> decimal place.
    >> do anyone of u know how?
    >> tq



  4. #4
    Danny Kalev Guest

    Re: float in 2 decimal point

    I would use a string data member instead of a float, and format the
    string as desired with a decimal point. Does that help?

    Danny Kalev

    "The ANSI/ISO C++ Professional Programmer's Handbook"
    http://www.amazon.com/exec/obidos/ASIN/0789720221


    Please reply to the newsgroup.


    hoon wrote:
    >
    > actually i'm using visual c++. and the problem here is, this is a control's
    > member variable where the value assign to it will get display automatically
    > when u call UpdateData. so i want to display the variable of type float in
    > two decimal point when UpdateData is call. do u know how?
    > tq.
    >
    > Danny Kalev <dannykk@inter.net.il> wrote:
    > >you can use the setprecision function if you're using iostreams. If
    > >you're using printf(), you need to use an appropriate string format:
    > >%2.2f.
    > >
    > >Danny Kalev
    > >
    > >http://www.amazon.com/exec/obidos/ASIN/0789720221
    > >Please reply to the newsgroup.
    > >
    > >hoon wrote:
    > >>
    > >> i have a problem displaying a control's member variable of type float

    > in two
    > >> decimal place.
    > >> do anyone of u know how?
    > >> tq


  5. #5
    hoon Guest

    Re: float in 2 decimal point


    thanks Danny,
    but i really need the variable to be in float as this variable will be used
    to compare to another varaible of type float, type checking..etc.
    is there anyway to set the properties of this control's data member to display
    only 2 decimal point?
    tq




    Danny Kalev <dannykk@inter.net.il> wrote:
    >I would use a string data member instead of a float, and format the
    >string as desired with a decimal point. Does that help?
    >
    >Danny Kalev
    >
    >"The ANSI/ISO C++ Professional Programmer's Handbook"
    >http://www.amazon.com/exec/obidos/ASIN/0789720221
    >
    >
    >Please reply to the newsgroup.
    >
    >
    >hoon wrote:
    >>
    >> actually i'm using visual c++. and the problem here is, this is a control's
    >> member variable where the value assign to it will get display automatically
    >> when u call UpdateData. so i want to display the variable of type float

    in
    >> two decimal point when UpdateData is call. do u know how?
    >> tq.
    >>
    >> Danny Kalev <dannykk@inter.net.il> wrote:
    >> >you can use the setprecision function if you're using iostreams. If
    >> >you're using printf(), you need to use an appropriate string format:
    >> >%2.2f.
    >> >
    >> >Danny Kalev
    >> >
    >> >http://www.amazon.com/exec/obidos/ASIN/0789720221
    >> >Please reply to the newsgroup.
    >> >
    >> >hoon wrote:
    >> >>
    >> >> i have a problem displaying a control's member variable of type float

    >> in two
    >> >> decimal place.
    >> >> do anyone of u know how?
    >> >> tq



  6. #6
    Nigel Holland Guest

    Re: float in 2 decimal point


    If I new a bit more about the control you were using I might be able to help.
    All I know at the moment is you are using a class with a parent of type CWind
    or a parent inherited from CWind.

    What type of control is it? Is it possible to define a mask for the control?

    Not sure but can't you use SetWindowText to set the text in what ever format
    you like. The window text is what's stored in the structure pointed to by
    m_hWnd (i.e. it calls the win32 API function SendMessage(m_hWnd, WM_SETTEXT,
    0, "Window Text"), this should not effect the data member of your control
    just the text displayed by the control.

    Try the windows forum, you'll get a better help in there, I'm a Unix programmer.

    "hoon" <siewhoon@geocities.com> wrote:
    >
    >thanks Danny,
    >but i really need the variable to be in float as this variable will be used
    >to compare to another varaible of type float, type checking..etc.
    >is there anyway to set the properties of this control's data member to display
    >only 2 decimal point?
    >tq
    >
    >
    >
    >
    >Danny Kalev <dannykk@inter.net.il> wrote:
    >>I would use a string data member instead of a float, and format the
    >>string as desired with a decimal point. Does that help?
    >>
    >>Danny Kalev
    >>
    >>"The ANSI/ISO C++ Professional Programmer's Handbook"
    >>http://www.amazon.com/exec/obidos/ASIN/0789720221
    >>
    >>
    >>Please reply to the newsgroup.
    >>
    >>
    >>hoon wrote:
    >>>
    >>> actually i'm using visual c++. and the problem here is, this is a control's
    >>> member variable where the value assign to it will get display automatically
    >>> when u call UpdateData. so i want to display the variable of type float

    >in
    >>> two decimal point when UpdateData is call. do u know how?
    >>> tq.
    >>>
    >>> Danny Kalev <dannykk@inter.net.il> wrote:
    >>> >you can use the setprecision function if you're using iostreams. If
    >>> >you're using printf(), you need to use an appropriate string format:
    >>> >%2.2f.
    >>> >
    >>> >Danny Kalev
    >>> >
    >>> >http://www.amazon.com/exec/obidos/ASIN/0789720221
    >>> >Please reply to the newsgroup.
    >>> >
    >>> >hoon wrote:
    >>> >>
    >>> >> i have a problem displaying a control's member variable of type float
    >>> in two
    >>> >> decimal place.
    >>> >> do anyone of u know how?
    >>> >> tq

    >



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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center