integer

Bash: Testing if a variable is an integer

Hello, I have a bash scripting question please. I would like to test if my variable $var is actually an integer or not. How can I please do that? Thank you very much, Jary ...

What's the origin of asking interviewees to manually parse a string as an int?

I'm wondering, what's the origin of asking interviewees to manually parse a string as an int? (without relying on any casting/type-conversion that may be built into the language). Is this a standard question, suggested from a book or list or something? Has anybody else here on SO gotten asked this particular question during an interv...

java: Integer equals vs. ==

As of java 1.5, you can pretty much interchange Integer with int in many situations. However, I found a potential defect in my code that surprised me a bit. The following code: Integer cdiCt = ...; Integer cdsCt = ...; ... if (cdiCt != null && cdsCt != null && cdiCt != cdsCt) mismatch = true; appeared to be incorrectly setting m...

How do flags work in c?

Ok I want to add some sort of flag like variable to one of my classes and had some questions about going about doing it. After looking at some source that uses it I noticed some stuff like this. TEXTUREFLAGS_POINTSAMPLE = 0x00000001, TEXTUREFLAGS_TRILINEAR = 0x00000010, Does the way this work is by combining all the flags into one int...

Getting a function to return two integers

I am writing a function and I want it two return two integers as results. However, I cannot get it to do this. Could someone help me? Here is my best shot public static int calc (int s, int b, int c, int d, int g) { if (s==g) return s; else if (s+b==g) return s && b; else if (s + ...

How to display hexadecimal numbers in C?

I have a list of numbers as below: 0, 16, 32, 48 ... I need to output those numbers in hexadecimal as: 0000,0010,0020,0030,0040 ... I have tried solution such as: printf("%.4x",a); // where a is an integer but the result that I got is: 0000, 0001, 0002, 0003, 0004 ... I think I'm close there. Can anybody help as I'm ...

Drupal: CCK Integer field type length?

What's the maximum length for the CCK Integer field type in Drupal? Thank you! ...

How to cast an Object to an int in java?

How can I cast an Object to an int in java? ...

Converting month name to integer

I did a quick search for this and was surprised not to find it anywhere. Basically looking to convert full month names (January, September, etc) to the equivalent number that would be used in mm/dd/yyyy format. I can put together my own array and pull it out accordingly, but there has to be a quick and straightforward method already. R...

Remove duplicates from a large integer array using Java

Hello all! Do you know of any time efficient way to remove duplicated values from a very big integer array using Java? The size of the array depends on the logged in user, but will always exceed 1500000 unsorted values with some duplicates. Every integer contains a number between 100000 and 9999999. I tried converting it to a List, but...

Convert int to ascii and back in Python

I'm working on making a URL shortener for my site, and my current plan (I'm open to suggestions) is to use a node ID to generate the shortened URL. So, in theory, node 26 might be short.com/z, node 1 might be short.com/a, node 52 might be short.com/Z, and node 104 might be short.com/ZZ. Something like that. And when a user goes to that U...

Integer vs double arithmetic performance?

Hi, i'm writing a C# class to perform 2D separable convolution using integers to obtain better performance than double counterpart. The problem is that i don't obtain a real performance gain. This is the X filter code (it is valid both for int and double cases): foreach (pixel) { int value = 0; for (int k = 0; k < filterO...

How to get a random integer in Freemarker template?

Is it possible to generate a random integer in Freemarker template? ...

Int and Double in one array in Java

Is there a way to put an int and a Double in the same array. I want to have an array (p1[]) where the first (p1[0]) is an int and all the rest of the elements are doubles. Is this possible? ...

In a PHP (Wordpress) loop how do you generate a sequence of unique numbers?

If I have a list being generated in a loop, something like: <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div id="slide"> <ul> <li class="slide-<?php //how can I generate an integer here ?>"> <a href="#">stuff</a></li> </ul> </div> How could I append a sequential number to each of those classes, and/or those hrefs...

Fastest integer type for common architectures

The stdint.h header lacks an int_fastest_t and uint_fastest_t to correspond with the {,u}int_fastX_t types. For instances where the width of the integer type does not matter, how does one pick the integer type that allows processing the greatest quantity of bits with the least penalty to performance? For example, if one was searching for...

C Programming Help with Int2String method

I am having trouble with my Int2String method. I am new to C so I am not sure if this would be the correct way to go about it. I'm receiving a few error messages: error: conflicting types for 'int2String' warning: return makes integer from pointer without a cast Here is my method: char int2String(int num, char intStr[10]) { char ito...

Python changes Integer in Float by itself

Hello, I'm trying to learn Python, (i have 2.5.4) by writing a snake game, but I'm stuck. Some integers change into floats and keep changing randomly, at least from my perspective :) The problem is that Snake.spawnPoint gets changed by Cam.move() print Snake.spawnPoint # first time, this returns '[25, 20]' ,which is good. Cam.Move() p...

how to convert NSArray to NSData...or something...

I am rather embarrassed to ask this, but I am on a time limit. basically, i need to get an array which can hold integers and then those integers can be used to plot a point on an image. I am trying to make a program where random objects travel down the screen following certain paths, but at random. So far this is my code: enemyPaths ...

Encoding a 5 character string into a unique and repeatable 32bit Integer

I've not given this much thought yet, so I might turn out to be a silly question. How can I take unique 5 ASCII character string and convert into a unique and reproducable (i.e needs to be the same every time) 32 bit integer? Any ideas? ...