Unsigned __int64 variable convertion to Float

Hello,

In my MFC program i have a Unsigned __int64 variable TimeStamp,
This time stamp is a value of time in nano seconds,
I need to convert this variable into float so that I can convert this variable into seconds and minutes as decimal value and the fractioned value as milli seconds

I am unable to convert this variable into a unsigned float variable (which can hold 8 bytes of data ).

Ex: TimeStamp = 34587692012 nano seconds
converting this value to seconds it will be 34.587692012 seconds (Formula is TimeStamp/1000000000)

please let me know the convertion type.
Thanks in advance.



You might want to use double instead of float. They're very similar, but double normally uses two times as much memory as float and is therefore more accurate.

Also there's no such thing as unsigned float or unsigned double, unlike integers, they're always signed.

1
2
3
4
5
double var = TimeStamp / 1000000000.0; // take note of the ending .0

// or if you want it to be more obvious

double var = static_cast<double> (TimeStamp) / 1000000000;


The point is, for the division to yield a double, at least one of the operands must be double.
Last edited on
Thanks for the support,

I have tried this but I am getting the following Errors:

error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64

For both of them.

I am getting below error

Currently I am working on Visual Studio 6.0

Visual Studio 6.0 is from 1998, it's old.

At this point, all I can suggest is that you install Service Pack 6 if you haven't, and try to compile the code again.

http://www.microsoft.com/en-us/download/details.aspx?id=9183
VS6 didn't properly support 64bit ints. For example the stream operators aren't implementd, no long long ...

You add these missing things yourself as you run into them.
Last edited on
Hello Cat,
Thanks for the support,
I tried with the Link but still it is not working.

let me know if you have any other solution
Topic archived. No new replies allowed.