In a previous post, I explored ways to compute the Math.min or Math.max for Numbers (http://guihaire.com/code/?p=550) What if we need to perform this operation when the floats are in a ByteArray ? Lets explore some interesting methods So our ByteArray contains a list of floats or numbers, the easiest way is to use the ternary […]

~ read more ~## Posts by

# Math.min Math.max float

In a previous post, I explored ways to accomplish Math.min and max for integers with some bit twiddling (http://guihaire.com/code/?p=549), Today, we are going to explore ways to find the min or the max of 2 Numbers without using the infamous Math class. Lets start with the min. So the basic: min = Math.min(i,j); One way […]

~ read more ~# Math.min Math.max integer tricks

Lets explore options today to fast get the min or the max of 2 integers values. Let’s start with the min, so we want to optimize: min = Math.min(i,j); One easy optimization is to use the ?: ternary operator to avoid the glue function call: min = (i<j)?i:j; we can replace the i<j by (i-j)>>31 […]

~ read more ~# Radix SortOn

In this post here, I presented a fast sorting function based on radix algorithm. Today, lets make the code a bit more useful by rewriting it to sort an array of objects, with a “key” string to access our sorting key. The desired API: static public function RadixSorOn(iarray:Vector.<Object> , sorted:Vector.<Object> , key:String):void As seen when […]

~ read more ~# More On Radix and FlashSort

Let’s see how well our FlashSort and RadixSort functions are performing under specific conditions: * when the keys in the array are uniques : ex:[9 7 8 1 3 2 5 6 4 7 8] * when the array is already sorted ex:[ 1 2 3 4 5 6 7 8 9] * when the […]

~ read more ~
## Recent Comments