Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Trying to convert a number string into an INT64 in VB.NET. The number I am testing with is 12804494279291877304.
The error I am getting is "Value was either too large or too small for an Int64."
Code sample below.
BigInt = CLng(EncodeNumber)
It's too big, doesn't fix in a INT64. It would fit in a UINT64.
Dim v As UInt64
v = UInt64.Parse("12804494279291877304")
Like #Çöđěxěŕ said, using TryParse allow the use of proper error handling.
If Not UInt64.TryParse("12804494279291877304", v) Then
' Handle wrong input
End If
Your number is too big for Int64, so you could use BigInteger, please see https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger?view=netframework-4.8
You can use unsigned Int64 as others suggest but beware that it won't hold negative numbers and also has a limit of 18446744073709551615
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a dataframe which looks as following:
df['col1'].values
array(['cat 113kd29', 'do56goat24kdasd', 'pig145kd'])
I need to create a new column df['vals'] with following values:
cat 29
do56goatasd
pig
i.e. first I need to look for substring kd and then find the numeric value preceding it. I am not sure how to go about this.
There can be multiple numeric values in each string so I need to find only ones before kd. Please note the string 'cat 113kd29'. Also look at 'do56goat24kdasd'
I tried the following but it didn't work:
df['col1'].str.replace(r'(\d+)kd', '')
Your call to str.replace is correct, but you need to assign it to the original Pandas column on the left hand side of an assignment:
df["col1"] = df["col1"].str.replace(r'\d+kd', '')
Note that str.replace does a global replacement by default, so there is no need to use any sort of flag.
Another way is to match digits precedingkd and kd and replace it with nothing
df["col1"]=df.col1.str.replace('\d+kd\Z','', regex=True)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a problem with Substring function. As you can see on Watch window shcreenshot I have the variable called val equal to 03.09.2015 17:30
I do not understand why but
val.Substring(0,2) returns 0 instead of 03
val.Substring(0,3) returns 03 (string of two symbols)
What am I doing wrong?
Your string contains non-printable characters. Note the following from your screenshot:
val = "03.09.2015 17:30"
val.Length = 21
However, 03.09.2015 17:30 only has 16 characters. Thus, the string contains other, zero-width characters.
To find the culprit, output a hex dump of your problematic string and compare it with the hex dump of the literal string 03.09.2015 17:30.
From OP comment:
The original problem was with Parse (and Parse-like) functions. It can not parse this string as Date or DateTime
Once the invisible characters are removed from the string, it certainly can be parsed:
Dim d As Date = DateTime.Parse("03.09.2015 17:30", Globalization.CultureInfo.InvariantCulture)
Dim m As Integer = d.Month ' m = 3
Of course, choose the particular Parse method that best fits your needs.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am trying to understand why I am getting an error in tf.get_session_tensor.
Below is my code:
https://github.com/subhobrata/Deep-Learning/blob/master/Untitled1.ipynb
Please help me with this error.
You declared type float32 in :
p, a = tf.get_session_tensor(h.handle, tf.float32)
however c is of type int, so you should declare it as such
p, a = tf.get_session_tensor(h.handle, tf.int32)
or change its type to float
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have table like this:
TABLE:
LOAD * INLINE [
SERVER
'SERVERNAME1'
'SERVERNAME2'
...
];
and loop:
FOR i = 1 to NoOfRows('TABLE')
LET v_TABLE = Peek('SERVER', $(i), 'TABLE');
LET v_SPECIFICATION = FieldName(1, $(v_TABLE));
trace $(v_TABLE);
...
STATEMENTS
...
NEXT
If I reload it, nothing happen, although for cycle runs thousand times, because the result of Peek() funcion is always NULL, not the value from table. Is the syntax incorrect, or is there some other mistake?
Sorry, my question was wrong. In Peek() function the third parameter wasn't string, but a variable (I didnt know that this will be mistake) and after many tries, I found out two things:
in my QV version 11.20 I have to call functions with variable parameter e.g. v_SPECIFICATION, not $(v_SPECIFICATION) (but not variable $(i), why???)
and rows in tables are numbered from zero (sometimes, as well), so this works for me:
LET v_TABLE = Peek('SERVER', $(i) - 1, v_SPECIFICATION);
Its really strange for me, but learning by doing...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to convert a SQL connection string into a String.Format line
The line that I need to convert is this:
WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID
Both thefull_name and cemetery_id are variables, but I have not idea how to construct the
String.Format line.
Seems you are looking for
Dim selectCommand = "SELECT * FROM mytable WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID"
Dim cmd = New SqlCommand(selectCommand, yourconnetion)
cmd.Parameters("#FullGraveNumber").Value = value1
cmd.Parameters("#CemeteryID").Value = value2
or
cmd.Parameters.AddWithValue("#FullGraveNumber", value)
First of all, ConnectionString is already a String with no parameters, it does not need to converted using String.Format. Usually stored in app.config, you feed it directly into SqlConnection object upon creation.
Part of the query that you have is also a String, but this time it may be substituted with parameters. However, please don't do so and use SQL parameters instead (see #huMpty's answer).
full_name and cemetery_id are SQL parameters, variables is something else.
My suggestion it to learn the terminology first, before you do any coding. No offense, it would benefit you a lot, because you would be able to ask a proper question. Proper question means a fast and qualified answer. Improper questions are usually closed. These are the rules of StackOverflow.