integer

JavaScript - Sort an array based on another array of integers

Say I have an array: [0,3,4,2,5,1] What i want to do is sort an array such as: ["one", "two", "three", "four", "five", "six"] so that the order corresponds to the first array. This would be the output: ["one", "four", "five", "three", "six", "two"] Is there an easy way to accomplish this? ...

algorithm for functions permutating integers

Hi, I want to write a function y = f(x) and another function x = g(y) that acts as a reversible, where y = f(g(y)) and where x and y are permutated integers. For very simple example in the range of integers in 0 to 10 it would look like this: 0->1, 1->2, 2->3,..., 9->10, 10->0 but this is the simplest method by adding 1 and reversin...

MySQL Cast NULL to integer 0

Hello. How can I cast something that returns NULL to 0? If this is my query: select col from table; would this be the right way to do it: select cast(col as unsigned integer) from table;? Thank you. ...

Is there any harm in having many enum values? (many >= 1000)

I have a large list of error messages that my biz code can return based on what's entered. The list may end up with more than a thousand. I'd like to just enum these all out, using the [Description("")] attribute to record the friendly message. Something like: public enum ErrorMessage { [Description("A first name is required for...

How do I declare a 32bit integer in java?

I'm looking at an app in java that runs on both 32bit and 64bit systems, and it deals mainly with IP addresses. These IP addresses are kept as integers, and the normal type for this wastes a ton of memory on 64bit platforms (and yes, memory use has already been shown to be an issue here). How do you declare 32bit integral values that s...