Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting Double to Float

0 views
Skip to first unread message

Charles Tam

unread,
Nov 10, 2005, 11:09:02 PM11/10/05
to
What is the correct way to convert a double value to float value?

For example:
//
double abc = 0.0000003534714494;
float xyz = (float) abc;
//

Brian Muth

unread,
Nov 10, 2005, 11:36:02 PM11/10/05
to
That'll do.

Brian

"Charles Tam" <Charl...@discussions.microsoft.com> wrote in message
news:A435C741-3C48-4BBE...@microsoft.com...

Frank Hickman [MVP]

unread,
Nov 11, 2005, 2:52:18 AM11/11/05
to
"Charles Tam" <Charl...@discussions.microsoft.com> wrote in message
news:A435C741-3C48-4BBE...@microsoft.com...

And also

float xyz= static_cast<float>( abc );

But you may want to check the value prior to casting to ensure you are not
losing any data...

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


0 new messages