Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  How Integers Should Work (In Systems Programming Languages)

My last post outlined some of the possibilities for integer semantics in programming languages, and asked which option was correct. This post contains my answers. Just to be clear: I want practical solutions, but I’m not very interested by historical issues or backwards compatibility with any existing language, and particularly not with C and C++.We’ll start with:Premise 1: Operations on default integer types return the mathematically correct result or else trap.This is the same premise that as-if infinitely ranged begins with, but we’ll perhaps end up with some different ...

2,110 0       ALGORITHM NUMBER SYSTEM EMBEDDED SYSTEM


  Gcd Algorithm with JavaScript

How to find the greatest common divisor betweentwo integers? We may encounter this problem frequently in interviews or otheroccasions.Anefficient metho to find gcd is the Euclideanalgorithm, whichuses the divisionalgorithm incombination with the observation that the gcd of two numbers also divides theirdifference: divide 48 by 18 to get a quotient of 2 and a remainder of 12. Thendivide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by6 to get a remainder of 0, which means that 6 is the gcd. Formally, it could bewritten asgcd(a,0)= agcd(a,b)= gcd(b...

10,855 2       JAVASCRIPT ALGORITHM GCD IMPLEMENTATION


  Permutation algorithm with JavaScript

In secondary school, we have learned permutation. Basically, for n numbers, the number of permutations for these n numbers can be calculated to n! which is called 'n factorial'. But to display all the permutations on the screen, we need to use a recursive function. The problem is how to write this function. Next I write a program to display the permutations for n numbers with JavaScript. First, we need to understand that from these n numbers, we can first take any one number from it, and the (n-1) numbers remaining has the similar property as the n numbers, we need to find the permutation...

34,885 0       JAVASCRIPT ALGORITHM PERMUTATION IMPLEME


  How Duff’s Device Works

I like C, but I have to admit that, sometimes, “The Old Man of Programming” can be a bit of a killjoy. This is one of the most exciting eras in computer history, but lately, C’s acting like he doesn’t evenwant to have a good time. While the cool kids like Ruby and Haskell are living it up, C’s over in the corner obsessing over bits and bytes and memory alignment and pointers and the stack and machine architecture and unreachable allocations and multiple indirections…and it’s…kind of a buzzkill. You want to tell him, “Dude! Lighten ...

2,377 1       DUFF DEVICE ALGORITHM SWITCH CASE