integer

Quick question regarding this issue, Why doesnt it print out the second value(converted second value) on the string?

Quick question, What have I done wrong here. The purpose of this code is to get the input into a string, the input being "12 34", with a space in between the "12" and "32" and to convert and print the two separate numbers from an integer variable known as number. Why doesn't the second call to the function copyTemp, not produce the value...

Why does my Perl program print the help message when an arguments has 0 as a value?

If i do this: GetOptions( 'u=s' => \$in_username, 'r=i' => \$in_readonly, 'b=i' => \$in_backup ); exit usage() unless $in_username && $in_readonly && $in_backup; and call the program like this: ./app.pl -u david -r 12 -b 0 it always results in calling usage(), so obviously the 0 is not seen as an integer value...

How to sum up an array of integers in C#

Is there a better shorter way than iterating over the array? int[] arr = new int[] { 1, 2, 3 }; int sum = 0; for (int i = 0; i < arr.Length; i++) { sum += arr[i]; } clarification: Better primary means cleaner code but hints on performance improvement are also welcome. (Like already mentioned: splitting large arrays). It's no...

MIPS division of signed integers

I'm wondering if anyone might know how to perform a division between two signed integers in MIPS, WITHOUT using the built in division operations. In the problem specs, I'm told the divisor register, ALU, and quotient register are all 32 bits wide, and the remainder register is 64 bits. ...

What is the easiest way to convert list with str into list with int? =)

Hello. What is the easiest way to convert list with str into list with int in python? =) For example, we have to convert ['1','2','3'] to [1,2,3]. Of course, we can use "for:", but it's too easy =) ...

In 64 bit systems, a 32 bit variable occupies less space than a 64 bit object?

The .NET Framework allocates less memory for a Int32 than for a Int64 in 64 bit systems? ...

A specific string format with a number and character together represeting a certain item

Hello there, I have a string which looks like this "a 3e,6s,1d,3g,22r,7c 3g,5r,9c 19.3", how do I go through it and extract the integers and assign them to its corresponding letter variable?. (i have integer variables d,r,e,g,s and c). The first letter in the string represents a function, "3e,6s,1d,3g,22r,7c" and "3g,5r,9c" are two separ...

need help with parseInt

hello, how can i get for example the integer codeInt=082 from String code='A082' i have tried this: int codeInt = Integer.parseInt(code.substring(1,4)); and i get codeInt=82 ,it leaves the first 0 but i want the full code '082'. i thought of parseInt(String s, int radix) but i don't know how . any help will be appreciated . thanks....

Implicit casting Integer calculation to float in C++

Is there any compiler that has a directive or a parameter to cast integer calculation to float implicitly. For example: float f = (1/3)*5; cout << f; the "f" is "0", because calculation's constants(1, 3, 10) are integer. I want to convert integer calculation with a compiler directive or parameter. I mean, I won't use explicit casting ...

Ruby Integer and Fixnum unexpexted behavior

I want to use gcd function of the Integer class. Using the example from Ruby Doc as a test it fails: irb(main):001:0> 72.gcd 168 NoMethodError: undefined method `gcd' for 72:Fixnum from (irb):1 I have the windows one click installer ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]. On other PCs with the same version of ru...

Entlib validation to syntax to accept only numeric month numbers?

I've got an enum defined as such: Private Enum AllowedMonthNumbers _1 _2 _3 _4 _5 _6 _7 _8 _9 _10 _11 _12 End Enum Then a property validator defined as: <TypeConversionValidator(GetType(Int32), MessageTemplate:="Card expiry month must be numeric.", Ruleset:="CreditCard")> _ <EnumConver...

Write set of integers to std::ofstream and be able to read them back

Hello, I need to write a bunch of unsigned integers to std::ofstream in binary mode: std::ofstream f; f.open("some path", std::ios::out | std::ios::binary); // some loop { unsigned int k = get_k(); // may product numbers from 0 to 65535 f << k; } f.close(); They are written to the output file "as is" w/o any delimiter. So when I'...

C: Comparing two long integers (very strange)

Hi, I have following situation (unix) : x is a long and has value 300 y is a long and has value 50000 if (x <= y) printf("Correct."); if (x > y) printf("Ouch."); Now I always get "Ouch". That means the program keeps telling me that 300 is greater than 50000! It only works again when I do if ((int)x <=(int) y) printf("Correct."); ...

Python, a smarter way of string to integer conversion

Hello I have written this code to convert string in such format "0(532) 222 22 22" to integer such as 05322222222 . class Phone(): def __init__(self,input): self.phone = input def __str__(self): return self.phone #convert to integer. def to_int(self): return int((self.phone).replace(" ","").repla...

What is a simple C library for a set of integer sets?

I've got to modify a C program and I need to include a set of unsigned integer sets. That is, I have millions of sets of integers (each of these integer sets contains between 3 and 100 integers), and I need to store these in some structure, lets call it the directory, that can in logarithmic time tell me whether a given integer set alre...

Why Java compiler does not like integer as type for values in HashMap?

The compiler complains about this code: HashMap<String,int> userName2ind = new HashMap<String,int>(); for (int i=0; i<=players.length; i++) { userName2ind.put(orderedUserNames[i],i+1); } It writes "unexpected type" and point on int. If I replace int by String and i+1 by i+"1", the compilation goes OK. What is wrong...

8 byte Integer with Doctrine and PHP

Hi, the players: 64bit linux with php 5 (ZendFramework 1.10.2) PostgreSQL 8.3 Doctrine 1.2 Via a Flash/Flex client i get an 8byte integer value. the field in the database is an BIGINT (8 byte) PHP_INT_SIZE show that system supports 8byte integer. printing out the value in the code as it is and as intval() leads to this...

Convert.ToInt or String.Split : which is more efficient?

Which way is better for removing float decimals places or is there a more efficient way? Rounding is not important, i am interested in displaying the number Float number; 1- int wholeNumber= Convert.ToInt(number); string display=wholeNumber.ToString(); 2- string [] splitNumber= number.ToString()....

32 bit unsigned int php

Hello! Does anyone know of a class/library/etc. that can simulate 32 bit unsigned integers on a 32 bit platform in PHP? I'm porting a C lib into PHP and it uses a lot of integers that are greater than the maximum for 32 bit signed int. ...

In java is it possible to pack a integer number that is expected not to be negative & be final (not overflow) into a short?

"Unsigned int" into a short and back. Is this possible? How to do it if so? Grrrr. I forgot how signed numbers are implemented. The question makes no sense. Thanks anyway. I was going to downvote myself, you can do it instead. ...