Convert float to double - weird failure
- From: tugboat90 <bmshipe@xxxxxxxxx>
- Date: 25 Oct 2007 20:10:42 -0700
Hello all,
I am trying to cast a float to a double (in C++) and am using the
static cast functionality. However, the value returned from the
static cast is not correct.
Example:
// Define a float
float f = 1.20000;
// Cast into a double - after the cast, the value of "d" is
// is "1.20000498297"
double d = static_cast<double> (f);
Is there some reason why the last few places are filled with garbage
now? I would have thought it would have been filled with 0's.
Any help would be much appriciated. Thanks!
.
- Follow-Ups:
- Re: Convert float to double - weird failure
- From: mike3
- Re: Convert float to double - weird failure
- From: CBFalconer
- Re: Convert float to double - weird failure
- From: Ben Pfaff
- Re: Convert float to double - weird failure
- Prev by Date: Re: Different CS Degrees
- Next by Date: Re: Convert float to double - weird failure
- Previous by thread: Re: NewsMaestro Usenet Supertool v. 4.0.2 for Windows/Linux/Unix
- Next by thread: Re: Convert float to double - weird failure
- Index(es):
Relevant Pages
|