nodatime - Way to use bit shift to move decimal place -


i working on library needs date math extremely quickly. using jon skeet's noda time library, uses tick math, , extremely quick, want elapsed seconds in way faster casting noda time instant or duration timespan.

the fastest way have been able far using ticks * 1e-07, thinking bit shifting might work faster (since 1e-07). in advance thoughts!

don't cast timespan - take ticks , divide nodaconstants.tickspersecond. it's integer division, , very, quick. given 107 isn't power of 2 (or particularly neatly represented combinations of them) suspect you'd best off dividing.

i'd surprised if division really proved bottleneck in code. while i'm trying keep noda time quick, i'm not above performing division or 2 appropriate :)

if need partial seconds, i'd tempted divide tickspermillisecond instead, , use integer number of milliseconds rather using floating-point arithmetic. if need double elsewhere, of course, that's not going much.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -