Click here to Skip to main content
15,895,142 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: An HTML5 platform to animate algorithms Pin
babakin8-Nov-13 11:11
babakin8-Nov-13 11:11 
GeneralRe: An HTML5 platform to animate algorithms Pin
Kornfeld Eliyahu Peter7-Nov-13 9:20
professionalKornfeld Eliyahu Peter7-Nov-13 9:20 
GeneralRe: An HTML5 platform to animate algorithms Pin
babakin8-Nov-13 11:12
babakin8-Nov-13 11:12 
GeneralRe: An HTML5 platform to animate algorithms Pin
Gopi Kishan Mariyala2-Dec-13 0:09
Gopi Kishan Mariyala2-Dec-13 0:09 
GeneralRe: An HTML5 platform to animate algorithms Pin
babakin3-Dec-13 11:59
babakin3-Dec-13 11:59 
AnswerRe: An HTML5 platform to animate algorithms Pin
Patrice T19-Sep-15 9:24
mvePatrice T19-Sep-15 9:24 
Questionceiling function bitwise operation [Solved] Pin
econy6-Nov-13 8:06
econy6-Nov-13 8:06 
GeneralRe: ceiling function bitwise operation Pin
harold aptroot6-Nov-13 8:57
harold aptroot6-Nov-13 8:57 
Certainly, but it's going to suck unless you make some assumptions.

For example, if x is known to be < 8 and bigger than -2 before the increment, then it's enough to do this:
C++
x++;
x -= x >> 3;
which subtracts 0 if x is already less than 8, otherwise x is 8 (because of the assumption) and it subtracts 1.

Or, if you have 32 bit ints (pretty common, and you can adapt it to other widths) and arithmetic shifts (you usually do) and x is known to be less than 8 and bigger than -2147483642 prior to the increment:
C++
x -= (x - 7) >> 31;

which effectively adds one if (x - 7) is negative (ie if x is less than 7)

Or, if you have 32 bit ints (adaptable), arithmetic shifts, and x is pretty much anything, you can do
C++
x++;
int mask = (x - 7) >> 31;
x = (mask & x) | (~mask & 7);

which uses the "bitwise minimum" trick, and it valid for almost all x, except x < 0x80000006 or x == 0x7fffffff
GeneralRe: ceiling function bitwise operation Pin
econy11-Nov-13 7:36
econy11-Nov-13 7:36 
GeneralRe: ceiling function bitwise operation [Solved] Pin
harold aptroot7-Nov-13 6:12
harold aptroot7-Nov-13 6:12 
GeneralRe: ceiling function bitwise operation [Solved] Pin
econy20-Nov-13 5:48
econy20-Nov-13 5:48 
GeneralRe: ceiling function bitwise operation [Solved] Pin
harold aptroot20-Nov-13 6:07
harold aptroot20-Nov-13 6:07 
GeneralRe: ceiling function bitwise operation [Solved] Pin
econy20-Nov-13 9:23
econy20-Nov-13 9:23 
QuestionSpiral Function Pin
push_coder30-Oct-13 18:41
push_coder30-Oct-13 18:41 
AnswerRe: Spiral Function Pin
Bernhard Hiller31-Oct-13 1:26
Bernhard Hiller31-Oct-13 1:26 
AnswerRe: Spiral Function Pin
Alan Balkany31-Oct-13 11:22
Alan Balkany31-Oct-13 11:22 
QuestionRandom Triangular Matrix Pin
Kyudos28-Oct-13 11:50
Kyudos28-Oct-13 11:50 
AnswerRe: Random Triangular Matrix Pin
BillWoodruff29-Oct-13 5:29
professionalBillWoodruff29-Oct-13 5:29 
GeneralRe: Random Triangular Matrix Pin
Kyudos29-Oct-13 14:01
Kyudos29-Oct-13 14:01 
QuestionPicking persons in a group algorithm Pin
Eduard Keilholz27-Oct-13 21:50
Eduard Keilholz27-Oct-13 21:50 
AnswerRe: Picking persons in a group algorithm Pin
Chris Losinger28-Oct-13 6:01
professionalChris Losinger28-Oct-13 6:01 
SuggestionRe: Picking persons in a group algorithm Pin
Richard Deeming28-Oct-13 12:57
mveRichard Deeming28-Oct-13 12:57 
AnswerRe: Picking persons in a group algorithm Pin
Richard Deeming29-Oct-13 2:45
mveRichard Deeming29-Oct-13 2:45 
GeneralRe: Picking persons in a group algorithm Pin
BillWoodruff29-Oct-13 5:22
professionalBillWoodruff29-Oct-13 5:22 
Questionusing genetic algorithms to improve voice commands recognition Pin
Member 997361615-Oct-13 0:24
Member 997361615-Oct-13 0:24 

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.