java - "Integer number too large" error message for 600851475143

600851475143 cannot be represented as a 32-bit integer (type int). It can be represented as a 64-bit integer (type long). long literals in Java end with an "L": 600851475143L... Read More

python - from list of integers, get number closest to a given value

If we are not sure that the list is sorted, we could use the built-in min() function, to find the element which has the minimum distance from the specified number. >>> min(myList, key=lambda x:abs(x-... Read More

parsing - How to parse a month name (string) to an integer for comparison in C#?

DateTime.ParseExact(monthName, "MMMM", CultureInfo.CurrentCulture ).Month Although, for your purposes, you'll probably be better off just creating a Dictionary<string, int> mapping the month's name t... Read More

ruby - Convert string with comma to integer

How about this? "1,112".delete(',').to_i... Read More

javascript - Convert boolean result into number/integer

Use the unary + operator, which converts its operand into a number. + true; // 1 + false; // 0 Note, of course, that you should still sanitise the data on the server side, because a user can send an... Read More

python - How can I check if a string represents an int, without using try/except?

with positive integers you could use .isdigit: >>> '16'.isdigit() True it doesn't work with negative integers though. suppose you could try the following: >>> s = '-17' >>> s.startswith('-') and s[1... Read More

integer - Declaring an unsigned int in Java

Java does not have a datatype for unsigned integers. You can define a long instead of an int if you need to store large values. You can also use a signed integer as if it were unsigned. The benefit o... Read More

casting - PostgreSQL: ERROR: operator does not exist: integer = character varying

I think it is telling you exactly what is wrong. You cannot compare an integer with a varchar. PostgreSQL is strict and does not do any magic typecasting for you. I'm guessing SQLServer does typecast... Read More

c - Is there any reason not to use fixed width integer types (e.g. uint8_t)?

It's actually quite common to store a number without needing to know the exact size of the type. There are plenty of quantities in my programs that I can reasonably assume won't exceed 2 billion, or... Read More

Converting integer to binary in python

>>> '{0:08b}'.format(6) '00000110' Just to explain the parts of the formatting string: {} places a variable into a string 0 takes the variable at argument position 0 : adds formatting options for t... Read More