Hi,
Is there any way to tell whether a string represents an integer (e.g., '3', '-17' but not '3.14' or 'asfasfas') Without using a try/except mechanism?
is_int('3.14') = False
is_int('-7') = True
Thanks,
Adam
...
I have two integer values a and b, but I need their ratio in floating point. I know that a<b and I want to calculate a/b, so if I use integer division I'll always get 0 with a remainder of a.
How can I force c to be a floating point number in Python when:
c = a / b
...
I was working with a variable that I had declared as an Integer and discovered that > is not a member of Integer. Here's a simple example:
scala> i
warning: there were deprecation warnings; re-run with -deprecation for details
res28: Integer = 3
scala> i > 3
<console>:6: error: value > is not a member of Integer
i > 3
^...
Hello,
I have a binary string, entered by the user, which I need to convert to an integer.
At first I naivly used this simple line:
Convert.ToInt32("11011",2);
Unfortunately this throws an exception if the user enters the integer directly.
Convert.ToInt32("123",2); // throws Exception
How can I make sure that the string entered b...
Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 2/2
1.0
Is this intended? I strongly remember earlier versions returning int/int=int? What should I do, is there a new division operator or must I always cast?
...
string sql="", sql2 = "", rank="";
int basic_wage, rent_allowance, seniority_allowance, overtime_rate;
sql += "select rank, Basic_Wage,Rent_Allowance,Seniority_Allowance,Overtime_rate from Designation_Details where Designation_ID=(select Designation_ID from Officer where Member_ID=" + id + ")";
sql2 += "select Overtime_Hours from Off...
I have a libpq program that is routinely inserting numbers into a database. These numbers, which I'm expecting to grow quite large, are stored int the uint64_t type. I'm wanting to send the integer to libpq as binary, but Postgres won't be able to tell its unsigned. Is there a way to specify an unsigned integer in Postgres or libpq?
...
What can be a reason for converting an integer to a boolean in this way?
bool booleanValue = !!integerValue;
instead of just
bool booleanValue = integerValue;
All I know is that in VC++7 the latter will cause C4800 warning and the former will not. Is there any other difference between the two?
...
I am having issues with pspell when searching for numeric values I end up with a blank white page and a segmentation fault in the server logs:
[Fri Aug 21 10:08:43 2009] [notice] child pid 30064 exit signal Segmentation fault (11)
When searching for a string everything works as expected. Below is the code I am using
$pspell_link = ps...
How do you compile integer data in Postgres by PHP?
My integers are string as the following show by var_dump ( $_SESSION )
'logged_in' => int 1
'user_id' => string '9' (length=1) // should be int
'a_moderator' => string '0' (length=1) // should be int
I compile the values by the following code which ...
In c++ you can do:
uint8 foo_bar
How would we do the same thing in ruby? Any alternatives?
This post seems close to it maybe someone can explain?
...
Hi
I am trying to convert char *str = "10.20.30.40" ; in to unsigned int . can u pls tell me any method is there or any sample code . pls share me.
...
I'm getting numbers like
2.36363636363636
4.567563
1.234566465448465
10.5857447736
How would i get ruby to round these numbers up (or down) to the nearest 0.05?
Thanks
...
Hi I have got a column in my database which is set to Int.
But my data always starts with a 0 so whenever I add a new record, it strips the 0 off and I don't want it to do that incase the first character has to be a 1 at some point.
How can I overcome this issue?
Is the best way to use VARCHAR any then validate using PHP?
Update
I...
I just have a simple question... How do I check to see if a textbox or a string contains an Integer?
please no code just maybe a hint or two :D
thanks all :)
...
The shellscript shown below will show a warning if the page takes more than 6 seconds to load.
The problem is that the myduration variable is not an integer. How do I convert it to integer?
myduration=$(curl http://192.168.50.1/mantisbt/view.php?id=1 -w %{time_total}) > /dev/null ; [[ $myduration -gt 1 ]] && echo "`date +'%y%m%d%H%M%S'`...
I'm trying to produce random integers (uniformly distributed).
I found this snippet on an other forum but it works in a very weird way..
srand(time(NULL));
AB=rand() % 10+1;
Using this method I get values in a cycle so the value increases with every call until it goes down again. I guess this has something to do with using the ti...
I'm working on a program where I store some data in an integer and process it bitwise. For example, I might receive the number 48, which I will process bit-by-bit. In general the endianness of integers depends on the machine representation of integers, but does Python do anything to guarantee that the ints will always be little-endian?...
As an exercise, I'd like to write a macro which tells me if an integer variable is signed. This is what I have so far and I get the results I expect if I try this on a char variable with gcc -fsigned-char or -funsigned-char.
#define ISVARSIGNED(V) (V = -1, (V < 0) ? 1 : 0)
Is this portable? Is there a way to do this without destro...
Hi
I have a project where I need to store a large number of values.
The data is a dataset holding 1024 2Byte Unsigned integer values. Now I store one value at one row together with a timestamp and a unik ID.
This data is continously stored based on a time trigger.
What I would like to do, is store all 1024 values in one field. So would ...