integer

bitwise AND in Javascript with a 64 bit integer

I am looking for a way of performing a bitwise AND on a 64 bit integer in JavaScript. JavaScript will cast all of its double values into signed 32-bit integers to do the bitwise operations (details here). ...

Question about sizeof. I want to reverse bits in number.

What will be equivalent of this in Java? for (i = (sizeof(num)*8-1); i; i--) num is given number, not array. I want to reverse bits in integer. ...

Appropriate data field type for true/false value?

Hi everybody, What's the most appropriate (read least data consuming) data field to store a true/false/1/0 value in a mySQL database? I have previously used a one character long tinyint, but I am not sure if it's the best solution? Thanks! ...

How to map (large) integer on (small in size( alphanumeric string with PHP? (Cantor?)

Dear all, I can't figure out how to optimally do the following in PHP: In a database, I have messages with a unique ID, like 19041985. Now, I want to refer to these messages in a short-url service but not using generated hashes but by simply 'calculate' the original ID. In other words, for example: http://short.url/sYsn7 should let me ...

How does Java handle integer underflows and overflows and how would you check for it?

How does Java handle integer underflows and overflows? Leading on from that, how would you check/test that this is occurring? ...

Convert String To Integer And Vice-Versa

I'm building a calculator application, and I have a Form, with a TextBox called txtVisor, that has the property NumbersOnly = true. I want to get the content of it(that I already know: txtVisor.Text) and convert it into a Integer, to do multiply it by 12, then convert the result into a String to set the txtVisor.Text as the result of the...

Beautify Integer values for comparing as strings

Hi. For some reason I need to enter my integer values to database as string, then I want to run a query on them and compare those integers as strings. Is there any way to beautify integer numbers (between 1 and 1 US billion as an example) so I can compare them as strings? Thanks in advance. ...

Android Float To Int

Why is this soo hard to find out? public boolean onTouch(View v, MotionEvent event) I need to convert float event.getY() to and int. Is this possible. event.getY().intValue() will not work at all. Any ideas? ...

How much storage space does the following take up?

int 72 It's a question in our discussion in a C# class. I said 2 bytes, others said it uses 32 bits or 4 bytes due to the integer type. Which is correct? ...

C programming, why does this large array declaration produce a segmentation fault?

This code produces a segmentation fault during the array declaration. I'm confused as to why this happens. I intentionally selected 2000000000 as a value because it is below 2^31 and can fit into an integer variable. int main() { int nums_size = 2000000000; int nums[nums_size]; int i; for(i = 0; i < nums_size; i++) ...

Hash 32bit int to 16bit int?

What are some simple ways to hash a 32-bit integer (e.g. IP address, e.g. Unix time_t, etc.) down to a 16-bit integer? E.g. hash_32b_to_16b(0x12345678) might return 0xABCD. Let's start with this as a horrible but functional example solution: function hash_32b_to_16b(val32b) { return val32b % 0xffff; } Question is specifically ab...

0 before the number

hi, i have an int. i want print it in this format: ex. 1 -> 000001 15 -> 000015 How can i do? thanks ...

C: How to find the length of an integer

Hello, I would like to know how I can find the length of an integer in C. For instance: 1 => 1 25 => 2 12512 => 5 0 => 1 etc. How can I do this in C? ...

Is there is some mathematical "optimum" base that would speed up factorial calculation?

Is there is some mathematical "optimum" base that would speed up factorial calculation? Background: Just for fun, I'm implementing my own bignum library. (-: Is this my first mistake? :-). I'm experimenting with various bases used in the internal representation and regression testing by printing out exact values (in decimal) for n facto...

convert string[] to int[]

Which is the fastest method for convert an string's array ["1","2","3"] in a int's array [1,2,3] in c#? thanks ...

What is the idiomatic way of performing an "integer " conversion/typecast in javascript?

Another question asked about the meaning of the code snippet a >>> 0 in Javascript. It turns out that it is a clever way of ensuring that a variable is a unsigned 32-bit integer. This is pretty neat, but I don't like it for two reasons. The intent of the expression is not clear, at least not to me. It does not work for negative nu...

Comparison between variables pointing to same Integer object

The ourput of current program is "Strange". But the both the variables share the same reference why are second and thrid comparison not true. Integer a; Integer b; a = new Integer(2); b = a; if(b == a) { System.out.println("Strange"); } a++; if(b == a) { System.out.println("Stranger"); } a--; if(b == a) { System.out.println(...

How to retrieve an integer value from a character?

How can I convert a character into an integer value? For example, I've been trying to read "A" as 1, "B" as 2, and so forth. I tried comparing the character to each letter in the alphabet and return the appropriate value. int intvalue(char letter) { if(letter == "A") return 1; else if(letter == "B") return 2; else if(letter == "...

Does C99 allow UCHAR_MAX > UINT_MAX

6.3.1.1 States The rank of a signed integer type shall be greater than the rank of any signed integer type with less precision. The rank of long long int shall be greater than the rank of long int, which shall be greater than the rank of int, which shall be greater than the rank of short int, which shall be greater than the rank of sig...

integerForKey: always returns zero

Hi, i'm trying to retrieve a value from my preference file which is an integer. The funny thing is that it always returns zero, although it does exist and the names for both integerForKey: and setIntegerForKey: are the same. Here's how I retrieve the value: [defaults integerForKey:@"BackUpSize"]; And here I set it: [defaults setIntege...