Click here to Skip to main content
16,014,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: x ==> next biggest power of two Pin
peterchen17-Mar-06 13:06
peterchen17-Mar-06 13:06 
AnswerRe: x ==> next biggest power of two Pin
Gordon Brandly17-Mar-06 7:47
Gordon Brandly17-Mar-06 7:47 
AnswerRe: x ==> next biggest power of two Pin
krmed17-Mar-06 10:06
krmed17-Mar-06 10:06 
GeneralRe: x ==> next biggest power of two Pin
Jörgen Sigvardsson17-Mar-06 10:49
Jörgen Sigvardsson17-Mar-06 10:49 
GeneralRe: x ==> next biggest power of two Pin
peterchen17-Mar-06 13:09
peterchen17-Mar-06 13:09 
GeneralRe: x ==> next biggest power of two Pin
krmed18-Mar-06 3:21
krmed18-Mar-06 3:21 
AnswerRe: x ==> next biggest power of two Pin
David Crow17-Mar-06 16:42
David Crow17-Mar-06 16:42 
AnswerRe: x ==> next biggest power of two Pin
cmk18-Mar-06 12:44
cmk18-Mar-06 12:44 
[EDIT]
Whoops, never mind.
Reread your question and realized you want to find where FkGrainUp2(S, G) == G.
[/EDIT]

FkGrain*N() - round S up/down to nearest multiple of G
FkGrain*2() - round S up/down to nearest multiple of G, where G must be a power of 2

Will work for all unsigned int types, not just unsigned long long.

ullong  FkGrainDnN( ullong S, ullong G )
{
	S = S - (S % G);
	return(S);
}

ullong  FkGrainUpN( ullong S, ullong G )
{
	ullong   r = S % G;
	if( r )  S = S + G - r;
	return(S);
}

ullong  FkGrainDn2( ullong S, ullong G )
{
	S = S & ~(G-1);
	return(S);
}

ullong  FkGrainUp2( ullong S, ullong G )
{
	G -= 1;
	S  = (S+G) & ~G;
	return(S);
}



...cmk

Save the whales - collect the whole set

-- modified at 18:49 Saturday 18th March, 2006
QuestionHow can I have a window with thick frame but no resize? Pin
Axonn Echysttas17-Mar-06 4:54
Axonn Echysttas17-Mar-06 4:54 
AnswerRe: How can I have a window with thick frame but no resize? Pin
basementman17-Mar-06 5:38
basementman17-Mar-06 5:38 
GeneralRe: How can I have a window with thick frame but no resize? Pin
Axonn Echysttas17-Mar-06 5:45
Axonn Echysttas17-Mar-06 5:45 
GeneralRe: How can I have a window with thick frame but no resize? Pin
PJ Arends17-Mar-06 6:00
professionalPJ Arends17-Mar-06 6:00 
AnswerRe: How can I have a window with thick frame but no resize? Pin
PJ Arends17-Mar-06 5:41
professionalPJ Arends17-Mar-06 5:41 
QuestionProblem with member static data initialization in win32 DLL Pin
Divick17-Mar-06 4:40
Divick17-Mar-06 4:40 
QuestionCFile::Remove; Use with network file Pin
Chris Meech17-Mar-06 4:21
Chris Meech17-Mar-06 4:21 
AnswerRe: Removes Egg from face Pin
Chris Meech17-Mar-06 4:41
Chris Meech17-Mar-06 4:41 
QuestionIntel based Macintosh - Windows General Question (??) Pin
Lampros Giampouras17-Mar-06 3:34
Lampros Giampouras17-Mar-06 3:34 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
Chris Losinger17-Mar-06 3:41
professionalChris Losinger17-Mar-06 3:41 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
Maximilien17-Mar-06 4:12
Maximilien17-Mar-06 4:12 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
jhwurmbach17-Mar-06 5:03
jhwurmbach17-Mar-06 5:03 
GeneralRe: Intel based Macintosh - Windows General Question (??) Pin
Lampros Giampouras17-Mar-06 6:38
Lampros Giampouras17-Mar-06 6:38 
GeneralRe: Intel based Macintosh - Windows General Question (??) Pin
jhwurmbach17-Mar-06 6:47
jhwurmbach17-Mar-06 6:47 
QuestionHow to Create Chevron Button Pin
BlueCrack17-Mar-06 3:10
BlueCrack17-Mar-06 3:10 
QuestionRe: How to Create Chevron Button Pin
toxcct17-Mar-06 3:36
toxcct17-Mar-06 3:36 
AnswerRe: How to Create Chevron Button Pin
BlueCrack17-Mar-06 3:38
BlueCrack17-Mar-06 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.