c++ - Storing the result of LARGE_INTEGER / LARGE_INTEGER -


i'm trying develop simple timer class game i'm making. right now, class calculate how long frame taking render fps calculations.

i using window's queryperformancecounter function (here) highest possible resolution (i got computer's counter frequency via queryperformancefrequency)

here function getting last frame's time in seconds:

void update_time() { last = current; counter(&current); last_frame_time = current.quadpart - last.quadpart; last_frame_time_secs = last_frame_time / timer_frequency.quadpart; }

currently, last_frame_time_secs double variable. when compile, warning:

 warning c4244: '=' : conversion 'longlong' 'double', possible loss of data 

and last_frame_time_secs 0.0. assume because result of division small doubles cannot store it? there larger data structure can use?

whoops, forgot doing integer division gets rid of fractional part, no matter how you're storing :) changing last line this:

last_frame_time_secs = (double)last_frame_time / (double)timer_frequency.quadpart; 

fixed it.


Comments

Popular posts from this blog

rest - Spring boot: Request method 'PUT' not supported -

php - Magento - Deleted Base url key -

symfony - imagine_filter() not generating the correct url in LiipImagineBundle -