integer

Parse negative numbers from string in perl

How do I parse a negative number from a string in perl? I have this piece of code: print 3 - int("-2"); It gives me 5, but I need to have 3. How do I do it? ...

Resetting a integer counter vb.net

If I have a double variable that goes through a loop and gets numbers added to it, is it just as simple as saying variablename = 0 to reset it? Jonesy ...

How to optimize this haskell snippet

Hi guys! I'm trying to create a small module for doing decimal-based calculations. A number is stored as an integer mantisse, with a precision value specified by an int: data APNum = { getMantisse :: Integer , getPrecision :: Int } For instance: APNum 123 0 -> 123 APNum 123 1 -> 1.23 APNum 123 2 -> 12.3 ... (negative precision...

User permissions as bits in an integer

Let's say I'm storing an integer for each user in a database that represents their assigned permissions. The number stored is the sum of the powers of two associated with each permission assigned. What's the easiest way to check to see if a certain permission was granted (within VBScript/ASP, or generally)? The best idea I have is to c...

Rails Migration to convert string to integer?

Hi Everyone, Is it possible to change a field that's a string to an integer without clearing the data already entered? The current db structure for the table in question is: create_table :people do |t| t.string :company_id Is this possible using migrations? I'm thinking maybe in the migration drop the old field, create a new one t...

Signed und Unsigned Integers in Preon

I want to use Preon for project that communicates with a server written in C. The protocol depends on the native endianess of the machine (you can solve with thisjava.nio.ByteOrder.getNative() under the assumption that the JVM has the same endianess as the server) and uses uint64_t for data lenghts and int32_t for status codes (a negativ...

how to define null as integer value on mysql server?

I need to allow saving null as integer value on mysql server, how can I do this? ...

Efficient algorithm for conversion between numeral system

Is there any efficient algorithm for conversion between numeral system when the size of source integer is arbitrary? For example, assume that there is an integer array {1, 4, 8} which is 148 in decimal format as an input. It might be converted to {9, 4} in hexadecimal format, or {2, 2, 4} in octal, or {1, 0, 0, 1, 0, 1, 0, 0} in binary ...

How do I save a matrix of integers to a text file in Matlab?

I have a 2D matrix myMatrix of integers which I want to save its content to a text file. I did the following: save myFile.txt myMatrix -ASCII I get this message: Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'myMatrix' not written to file. and nothing is written. What to do? ...

How to convert an integer to variable length byte string?

I want to convert an integer (int or long) a big-endian byte string. The byte string has to be of variable length, so that only the minimum number of bytes are used (the total length length of the preceding data is known, so the variable length can be inferred). My current solution is import bitstring bitstring.BitString(hex=hex(456))...

Java collections: What happens when "size" exceeds "int"?

I know that Java collections are very memory-hungry, and did a test myself, proving that 4GB is barely enough to store few millions of Integers into a HashSet. But what if I has "enough" memory? What would happen to Collection.size()? EDIT: Solved: Collection.size() returns Integer.MAX when the integer range is exceeded. New question: ...

Best way to get integer part of the string "600sp"???

I have a string, say "600sp" from which I wish to obtain the integer part (600). If I do Integer.valueOf("600sp") I get an exception due to the non-numeric value "s" which is encountered in the string. What is the fastest cleanest way to grab the integer part? Thanks! ...

How to convert Integer to int?

Now, i am working on a web application in which data will be transfer between client & server side. I already know that JavaScript int != Java int. Because, Java int cannot be null, right. Now this is the problem i am facing. I changed my Java int variables into Integer. public void aouEmployee(Employee employee) throws SQLExcepti...

When you alter a table how do you detect the data type of columns?

I am running MySQL and I need to change the data type of certain columns from an enumeration to integer. However, there are a lot of columns. (If this exists) What is the syntax to alter all columns at the same time that are enumerations. Here is how I am updating a single column to make it integer data type: ALTER TABLE table_name CHAN...

What's the easiest way to get the binary representation of an integer?

Actually, I'm not asking how to implement this functionality myself. I know it wouldn't be very complicated. I just don't want to reinvent the wheel, so I was wondering if this functionality exists somewhere in the BCL. It seems like surely it's there somewhere... Example input/desired output: Input Output 1 1 2 ...

C - floor of double moduls integer

I need to do the following equation floor(e%100000) where e is a double. I know mod only accepts int values, how do I go about achieving this same result? Thanks ...

Is there a LARGEST_INTEGER macro or something similar? (C)

Possible Duplicates: How would you set a variable to the largest number possible in C? maximum value of int I need to use the maximum integer value in my my code, but I don't want to explicitly write 4294967295. Is it defined somewhere? ...

Convert INT(0-255) to UTF8 char in Java

Hi, since I need to control some devices, I need to send some bytes to them. I'm creating those bytes by putting some int values together (and operator), creating a byte and finally attaching it to a String to send it over the radio function to the robot. Unfortuantely Java has some major issues doing that (unsigned int problem) Does ...

Groovy - Type testing?

Hello all, I'm really brand new to Groovy and I'm trying to get something done. I've written some Groovy code (which works just fine) which receives some text. This text should be an integer (between 0 and 10). It may just happen a user enters something different. In that case I want to do some specific error handling. Now I'm wonderin...

Cache key causes error "Negating the minimum value of a twos complement number is invalid."

This is one of the strangest errors I've ever seen. I'm doing a very simple call to return values from the HttpRuntime cache. The call is: return HttpContext.Current.Cache[cacheKey]; If it returns null, that's fine. I check if the returned value is null and act accordingly. I've been using this call for a long time. Recently, for...