View Single Post
Old 22nd September 2019, 21:14   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
MeteorRain,
Note, BitAnd() is a function, with significant lookup overhead (although not so much in avs+ compared to avs std, I think hash table was implemented in avs+),
whereas ops below are done directly via the parser, and quite a bit faster [will though make little difference unless in some runtime script].
Code:
        \   (RoundMode==0)  ?   value / factor * factor              [* Down                   *]
        \ : (RoundMode==1)  ?   (value*2+factor)/(2*factor)*factor   [* Nearest : About same as (value+factor/2)/factor*factor but without intermediate result precision loss *]
        \ : (RoundMode==2)  ?   (value+factor-1)/factor*factor       [* Up                     *]
        \ : (RoundMode==3)  ?   (value-1)/factor*factor              [* ALWAYS_DOWN : Rare Use <EDIT: Result always less than Value, except where Value=0> *]
        \ :                     (value+factor)/factor*factor         [* ALWAYS_UP   : Rare Use <EDIT: Result always greater than Value> *]

EDIT: Also, I suggest that method that works for all values of factor is a better option, with possible exception being above Simpler Nearest when factor is power of 2(1,2,4 etc, likely most often).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 23rd September 2019 at 10:46.
StainlessS is offline   Reply With Quote