Click to See Complete Forum and Search --> : float in 2 decimal point


hoon
03-13-2000, 04:53 AM
i have a problem displaying a control's member variable of type float in two
decimal place.
do anyone of u know how?
tq

Danny Kalev
03-13-2000, 02:45 PM
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

hoon
03-13-2000, 08:29 PM
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

Danny Kalev
03-13-2000, 09:47 PM
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

hoon
03-13-2000, 10:24 PM
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

Nigel Holland
03-14-2000, 04:41 AM
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
>