Skip to main content
GameDev.net gamedev.net
🔒 Locked

CTime

Started by original vesoljc Aug 30, 2003 at 8:55 PM 5 replies 400+ views
Original Post
original vesoljc
original vesoljc
i''m working on a my own CTime and CTimeSpan. i want "large" time and i want precise time, so i thought of using two varibales: a uint64 for seconds and a real64 for fractions of seconds. ie: uint64 mWSec; (a LOT of seconds ) real64 mFSec; (a LOT of "fractions") so the whole time would be something like mWSec.mFSec while (mFSec > 1.0) { mFsec -= 1.0; ++mWSec; } would this be good enough?
Abnormal behavior of abnormal brain makes me normal...
JohnBolton
JohnBolton
Consider this first: if you use a signed 64-bit to represent nanoseconds, the range of the variable is –9,223,372,036.854775808 seconds to 9,223,372,036.854775807 seconds, or approximately +/- 292 years. If the time is in microseconds, then you can represent up to +/- 292,000 years.

Would this be good enough?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
original vesoljc
original vesoljc
what''s 292 years in the long run? :D

so, ur saying to use 64bit int for nanosec''s?
Abnormal behavior of abnormal brain makes me normal...
original vesoljc
original vesoljc
"time scaling" must also be available, soo 292 years is "nothing"
Abnormal behavior of abnormal brain makes me normal...
JohnBolton
JohnBolton
quote:
Original post by original vesoljc
what''s 292 years in the long run? :D

so, ur saying to use 64bit int for nanosec''s?


You didn''t say what kind of range and precision you needed. I was just pointing out that even with nanosecond precision, a 64-bit int may have a sufficient range.

If 64-bits isn''t enough, then my recommendation is to go with standard fixed-point math, instead of your complicated system. The math will be much simpler and more precise. And some compilers support 128-bit arithmetic!
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
original vesoljc
original vesoljc
never thought of fixed point... write now i''m doing an emulation of it
Abnormal behavior of abnormal brain makes me normal...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.