integer

Javascript check for decimal place (check if value is an integer)

Hi, i am looking for an easy way in javascript to check if a number has a decimal place in it (is an integer) ... 23 -> OK 5 -> OK 3.5 -> not OK 34.345 -> not OK if(number is integer) {...} thx alot. ...

How do I specify an integer literal of type unsigned char in C++?

I can specify an integer literal of type unsigned long as follows: const unsigned long example = 9UL; How do I do likewise for an unsigned char? const unsigned char example = 9U?; This is needed to avoid compiler warning: unsigned char example2 = 0; ... min(9U?, example2); I'm hoping to avoid the verbose workaround I currently h...

Integer comparison in python slows everything down to a crawl

The following code is causing me enormous headaches: def extract_by_letters(letters, dictionary): for word in dictionary: for letter in letters: if word.count(letter) != letters.count(letter): if word in dictionary: #I cant leave this line out dictionary.remove(word) return d...

Convert String.Empty to Nothing/Null

Is there a .Net function that does that. I guess if there isn't i have to make my own method. The thing is i have a function. It accepts integers. If you pass a 0 integer or a null value it still works. Problem is that the value of an empty textbox is a String.Empty value. I don't want to use if's. I mean it could but its much nicer i...

How to configure Visual Studio to show integers as decimals when debugging?

My Visual Studio 2008 debugger is showing integers as hexadecimals, how to correct that? ...

App crashes when I create a NSDictionary with integer as Object

Hello, Always when I try to set an integer as Object in a NSDictionary the program crashes without a message (nothing in the console). What is wrong in this code? : NSString *string = @"foo"; int number = 1; NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: string, @"bla1", number, @"bla2",nil...

How to set up C++ Number Formatting to a certain precision?

Hi, I understand that you can use iomanip to set a precision flags for floats (e.g. have 2.0000 as opposed to 2.00). Is there a way possible to do this, for integers? I would like a hex number to display as 000e8a00 rather than just e8a00 or 00000000 rather than 0. Is this possible in C++, using the standard libraries? ...

Get int from String, also containing letters, in Java

How can I get the int value from a string such as 423e - i.e. a string that contains a number but also maybe a letter? Integer.parseInt() fails since the string must be entirely a number. ...

Evenly distributed integers within a range

Lets say I have a range between 0 and 100 and I want an array returned containing 3 integers which are evenly distributed within that range, what would be the best way to do this? For example: Range: 0-100 Wanted: 3 Returned: 25, 50, 75 ...

Variable length integer encoding

I am attempting to reverse engineer an LZ1/LZ77 decompression algorithm. The length of an area of the decode buffer/window to be output is encoded in the file as a variable length integer. I've read as much as I can about variable length integer encoding and the method being used in this case does not appear to be like any others I ha...

C++ type conversion

Where can I find an overview of type conversion, e.g. string to integer, etc.? Because of the comments so far, I'll clarify: I'm looking for a list /table that says: To convert a string to an int, use: ... And same for other data types (where possible): double to int, char to string, ... ...

How do you round UP a number in Python?

This problem is killing me. How does one roundup a number UP in Python? I tried round(number) but it round the number down. Example: round(2.3) = 2.0 and not 3, what I would like The I tried int(number + .5) but it round the number down again! Example: int(2.3 + .5) = 2 Then I tried round(number + .5) but it won't work in edge cas...

How stupid it is to use an integer value a key for an Hash Table?

Hi, I'll be needing to use Hash Tables with different keys. One as string for the key and another as integer. As for the integer one, how stupid it is to run a hash function on the number to generate a key? I mean, the numbers I'll be using as key for the Hash Table will always be different, there will be no duplicates at all. Isn't e...

Generate 8 unique random numbers between 1 and 100

Hey guys, i have trouble generating unique random numbers using js. Can someone lend me a hand? ...

Why doesn't Java throw an Exception when dividing by 0.0?

I have code to calculate the percentage difference between 2 numbers - (oldNum - newNum) / oldNum * 100; - where both of the numbers are doubles. I expected to have to add some sort of checking / exception handling in case oldNum is 0. However, when I did a test run with values of 0.0 for both oldNum and newNum, execution continued as if...

Convert an integer into a signed string in Ruby

I have a report in which I'm listing total values and then changes in parentheses. E.g.: Songs: 45 (+10 from last week) So I want to print the integer 10 as "+10" and -10 as "-10" Right now I'm doing (song_change >= 0 ? '+' : '') + song_change.to_s Is there a better way? ...

Fortran: handling integer values of size: ~700000000000

Hey All... Currently I'm brushing up on my Fortran95 knowledge (don't ask why)... I'm running in to a problem though. How does one handle large integers, eg. the size of: ~700000000000 INTEGER(KIND=3) cannot hold this number. If anyone is interested the compiler I have available is Silverfrost FTN95. I am using the integer to run thr...

testing a string to see if a number is present and asigning that value to a variable while skipping all the non-numeric values?

Hi there, given a string say " a 19 b c d 20", how do I test to see if at that particular position on the string there is a number? (not just the character '1' but the whole number '19' and '20'). char s[80]; strcpy(s,"a 19 b c d 20"); int i=0; int num=0; int digit=0; for (i =0;i<strlen(s);i++){ if ((s[i] <= '9') && (s[i] >= '0')){...

Is there a DivMod that is *not* Limited to Words (<=65535)?

In Delphi, the declaration of the DivMod function is procedure DivMod(Dividend: Cardinal; Divisor: Word; var Result, Remainder: Word); Thus, the divisor, result, and remainder cannot be grater than 65535, a rather severe limitation. Why is this? Why couldn't the delcaration be procedure DivMod(Dividend: Cardinal; Divisor: Cardinal;...

Flex Null Integer

Hi; I take data from Java to Flex by AMF (BlazeDS) In java side object has Integer field. So it can be null. In Flex side object is int. So null values are deserialized as 0. This is not what I want, I want to see whether it is 0 or null. Is there wrapper like (Integer in Java) for Flex? Thanks ...