Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOUBLE to LONG INT conversion

Status
Not open for further replies.

davidchardonnet

Programmer
Mar 21, 2001
167
FR
Hello,

I have a problem with Visual C++ compiler. The problem is in data conversion between LONG INT and DOUBLE. And the same occurs with INT and DOUBLE. Does anybody know how I can make it work? Here is the sample code:
-----------------------------------------------------------
double time_double_miliseconds;
double time_double_seconds;
long time_long_seconds;

...
// Here time_double_miliseconds contains 14.400000

time_double_seconds=(1000.0 * time_double_miliseconds);

// Here time_double_seconds contains 14400.00000

time_long_seconds = time_double_seconds;

// Here time_long_seconds contains 14399 !!!!!
-----------------------------------------------------------

What I want is to get 14400 into time_long_seconds. And I don't know why the compiler does this.

Thank you for your answers

David CHARDONNET
 
hi
use it
time_long_seconds = time_double_seconds;
time_long_seconds++
 
time_long_seconds = static_cast<long>(time_double_seconds); John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top