int

Get length of bits used in int

If you have the binary number 10110 how can I get it to return 11111? e.g a new binary number that sets all bits to 1 after the first 1, there are some likewise examples listed below: 101 should return 111 (3 bit length) 011 should return 11 (2 bit length) 11100 should be return 11111 (5 bit length) 101010101 should return 111111111 (9 ...

Integer output in Java method not same as pre-converted char value.

I'm trying to parse a simple text file in an integer method and then output an integer from such file so that other parts of the program can use it. For testing purposes it also displays the character value (9 in this case). The integer value for some reason is 57. I've also tried it with another part of the text file (which in that case...

AspectJ join point with simple types

Hi! Are there defined join points in arithmetics that I can catch? Something like: int a = 4; int b = 2; int c = a + b; Can I make a pointcut that catches any one of those lines? And what context will I be able to get? I would like to add a before() to all int/float/double manipulation done in a particular method on a class, is tha...

Byte from string/int in C++

Hi, I'm a beginning user in C++ and I want to know how to do this: How can I 'create' a byte from a string/int. So for example I've: string some_byte = "202"; When I would save that byte to a file, I want that the file is 1 byte instead of 3 bytes. How is that possible? Thanks in advance, Tim ...

How to find that a value is less than 108 and greater than 0 in JavaScript: something wrong in script

I write this code for checking: var num = $("#knum").val(); if (isNaN(parseInt(num))) { $("#errorknum").html("Please define a number."); } else { if (num < 1 | num > 249) { $("#errorkrnum").html("your number must be less then 249 and can be greater than 1"); } ...

What is the maximum value of an unsigned 64-bit integer in English?

What is the maximum value of an unsigned 64-bit integer in English? ...

Procedure in converting int to decimal data type?

I have an int(11) column which is used to store money. I read some of the answers on SO and it seems I just need to update it to be a decimal (19,4) data type. Are there any gotchas I should know about before I actually do the converting? My application is in PHP/Zend and I'm not using an ORM so I doubt I would need to update any sort o...

Else statement crashes when i enter a letter for a cin << int value

Alright, I have a question, I veered away from using strings for selection so now I use an integer. When the user enters a number then the game progresses. If they enter a wrong character it SHOULD give the else statement, however if I enter a letter or character the system goes into an endless loop effect then crashes. Is there a way to...

Why do I get corrupt output on my file?

I have a simple program which I have compiled in both MinGW and Visual C++ 2008 Express, and both give an output file larger than 88200. When I set s = 0, both programs work as expected. What am I doing wrong? #include <fstream> using namespace std; int main(int argc, char *argv[]) { int i; short s; fstream f; f.op...

How can I set an int value in some code to be equal to a value in a text entry box?

I'm trying to get a value from an object in my mac application. The title says it all. ...

casting size_t to int to declare size of char array

I am trying to declare a size of a char array and I need to use the value of the variable that is declared as a size_t to declare that size. Is there anyway I can cast the size_t variable to an int so that I can do that? ...

is int? thread safe?

I know that in .net any 32bit type (int, bool, etc) are threadsafe. you know that there won't be a partial write ever (according to the spec). Does the same apply for int? (nullable int) ...

JOptionPane Input to int

Hello all, I am trying to make a JOptionPane get an input and assign it to an int but I am getting some problems with the variable types. I am trying something like this: Int ans = (Integer) JOptionPane.showInputDialog(frame, "Text", JOptionPane.INFORMATION_MESSAGE, null, null, ...

PHP: Very simple Encode/Decode string

Is there any PHP function that encodes a string to a int value, which later I can decode it back to a string without any key? ...

Turn NSString into integer

Sorry guys, I'm a noob. I know that some languages support type casting, but when I tried to do that here it failed, miserably. I've got an UITextField with number only pad, so I'm only getting numbers, and I need the output from that in my int, diff. Here's what I tried: NSString *outputNumber = [NSString stringWithFormat:@"%d", [textB...

Mysql select order by acts like a string, not a number

How do you order by number if your number can fall below and be bigger than 0? Example Mysql table: |Name|Karma| __________ |Me | -8 | |Bill| 5 | |Tom | 2 | |Saly| 0 | |San.| -3 | Example select query $sql="SELECT karma FROM table ORDER BY karma DESC"; The result I get is this (separated by comma): 5,2,0,-8,-3. Shouldn't...

Invalid recever type int

Hi! I cant sem to find what would be the problem here... NSArray *oneMove; oneMove = [[bestMoves objectAtIndex:i] componentsSeparatedByString:@","]; int from, to; int temp = [[oneMove objectAtIndex:0] intValue]; from = [temp intValue]/100; //"Invalid receiver type int" to = [temp intValue]%100; //"Invalid receiver type int" NSLog(@...

int array size changes

Possible Duplicate: Sizeof an array in the C programming language? Why is the size of my int array changing when passed into a function? I have this in my main: int numbers[1]; numbers[0] = 1; printf("numbers size %i", sizeof(numbers)); printSize(numbers); return 0; and this is the printSize method void printSize(int numb...

How to elegantly check if a number is within a range?

How can I do this elegantly with C# and .Net 3.5/4? For example a number can be between 1 and 100. Edit: I know a simple if would suffice; but the keyword to this question is elegance. It's for my toy project not for production. Edit 2: This questions wasn't about speed but about code beauty. Stop talking about efficiency and such; re...

How to set an int to byte* C#

How can I convert an int to a byte* at a certain index in a byte*? Ideally I would like to have something like: unsafe{ byte* igm=stackalloc byte[8]; igm[4]=4283; } It would set the first part of the bit to igm[4] and the rest into igm[5]. Edit: I realize there may be a lot of possible ways to handle this, i am looking for...