Currently attempting to divide an unsigned long long by a static value.
The unsigned long long contains the number of microseconds it took for an operation to complete. I want to take this value and convert it into seconds.
Here is the code snippit:
double udDiffTime = ullHighResDiffTime / (unsigned long long)1000000;
In one case with my debugger, I can see ullHighResDiffTime = 639. Therefore, udDiffTime = 0.000639. However, I'm getting udDiffTime = 0.
I'm sure I'm making a mistake somewhere. I've tried using 1000000LL instead of casting it using (unsigned long long), but there is no difference.
You're doing an integer division, thus if the result is 0.000639 it will get truncated to 0.
If you want a floating-point result, you'll have to use at least one floating-point operand. Try for instance to change (unsigned long long) 1000000
to 1000000.0
.
An unsigned long long can range up to 18,446,744,073,709,551,615. A double
can reach up to 1.7E308 (i.e., a one with 308 zeros). The catch is that the higher the value gets, the less precision it will have, so what you need to ask yourself is if the large values really need to be that precise, or if it's more important which magnitude the number has.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With