integer

PHP check if variable is a whole number

I have this PHP code: $entityElementCount = (-($highScore-$totalKeywordCount))/0.29; What i want to know is, how to check whether $entityElementCount is a whole number (2, 6, ...) or partial (2.33, 6.2, ...). Thank you! ...

Length of an integer in python

In python, is there a command similar to len() which works on integers? Thanks ...

Adding integer values as contents of an array,iphone

I need to store some integer values as the contents of an array. But when i try to do so, it throws a warning, passing argument 1 of 'addObject' makes pointer from integer without a cast. And obviously the value is not stored in the array. Here's thecode. NSUInteger i; for (i=0;i<5;i++){ [array addObject:i];} ...

How can I determine the relationship of C integer type MIN/MAXes in the preprocessor?

I’m trying to determine the relationship of a given compiler’s integer types’ sizes using the preprocessor. My requirement is that I have two types, one of which is unsigned, and one of which is a signed type capable of storing every positive number that said unsigned type can store. i.e. I have to ensure that my ll_ssize type can store ...

How do I pass a static method to comp in clojure?

It seems as though I'm having problems accessing Integer.parseInt in comp. I can access it normally like this: user=> (Integer/parseInt "123") 123 But if I put it in comp, I get an error: user=> (def vect-to-int (comp Integer/parseInt (partial apply str))) java.lang.Exception: Unable to find static field: parseInt in class java.lang...

BASH: Test whether string is valid as an integer?

Hello All, I'm trying to do something common enough: Parse user input in a shell script. If the user provided a valid integer, the script does one thing, and if not valid, it does something else. Trouble is, I haven't found an easy (and reasonably elegant) way of doing this - I don't want to have to pick it apart char by char. I know t...

Bitwise operation on floating point numbers (for graphics)?

Possible Duplicate: how to perform bitwise operation on floating point numbers Hello, everyone! Background: I know that it is possible to apply bitwise operation on graphics (for example XOR). I also know, that in graphic programs, graphic data is often stored in floating point data types (to be able for example to "multiply"...

Best way to handle a lot of ints

I have an array of about 10-100k ints that I need to store (as compressed as possible), and retrieve back to the complete array the fastest way possible. What is the best way to handle this type of thing in a language like c#. ...

C: Obfuscating an integer

If I have an integer like this in several places in my code... int my_secret = 42; ... is it possible to make it more difficult to find that integer in the compiled program? I've seen this done with strings, for example by shifting each letter by x characters and then un-shifting them at runtime, but I doubt this technique would work ...

String to Integer Smalltalk

Pretty simple question I need to get an integer from the user and I only know how to get a string from them. So if there is a way to get an integer from the user or to convert the string to an integer please let me know. ...

formatting currencies with Python

I would like to format integers as professional looking currency strings. For example: 1200000 -> $1.2 million 456 -> $456.00 Do you know a good library for this, ideally with localization to handle European formats. ...

Writing an integer to a file with fputs()

It's not possible to do something like fputs(4, fptOut); because fputs doesn't like integers. How can I work around this? Doing fputs("4", fptOut); is not an option because I'm working with a counter value. ...

BestPractice for conditions with strings and numbers

I just wonder how to write a number that has to be expressed as string. For instance: if (SelectedItem.Value == 0.ToString()) ... or if (SelectedItem.Value == "0") ... or public const string ZeroNumber = "0"; if (SelectedItem.Value == _zeroNumber) ... or if (Int.Parse(SelectedItem.Value) == 0) ...

Coldfusion convert number to text

I have a coldfusion app in which I calculate the number remaining of a certain object. So I have a integer... like 9. But I need to print it to the screen in text form.... like nine. Is there a built in function to do this? I googled and couldn't find one. ...

how to store a very long integer value in c program for exam :- 98474737475747374739399

I have so store a very long value of type integer that can't be stored in a variable of long type. how can i store such a long integer value in a c programme. Please illustrate it through an example/ programme if possible. ...

RGB Int to RGB - Python

How can I convert an RGB integer to the corresponding RGB tuple (R,G,B)? Seems simple enough, but I can't find anything on google. I know that for every RGB (r,g,b) you have the integer n = r256^2 + g256 + b, how can I solve the reverse in Python, IE given an n, I need the r,g,b values. ...

Is there a built-in or more Pythonic way to try to parse a string to an integer

I had to write the following function to fail gracefully when trying to parse a string to an integer. I would imagine Python has something built in to do this, but I can't find it. If not, is there a more Pythonic way of doing this that doesn't require a separate function? def try_parse_int(s, base=10, val=None): try: return int(s...

How would you set a variable to the largest number possible in C?

How would you set a variable to equal infinity (or any guaranteed largest number value) in C? ...

Size of integers?

This has to do with a question I read yesterday: http://stackoverflow.com/questions/2274428/how-to-determine-how-many-bytes-an-integer-needs Anyway, the part that I have a question about is this: I'm looking for the most efficient way to calculate the minimum number of bytes needed to store an integer without losing precision. ...

Pros and cons of ways of storing an unsigned int without an unsigned int data type

I have values that are 64-bit unsigned ints, and I need to store them in mongodb, which has no unsigned int type. I see three main possibilities for storing them in other field types, and converting on going in and out: Using a signed int is probably easiest and most space efficient, but has the disadvantage that they're not human reada...