I am trying to pass 6 values instead of a value.
//function that contains the value
siteNEVObjectdic::siteNEVObjectdic(double iLat1, double iLong1, double iLat2, double iLong2, double iLat3, double iLong3)
{
Lat1=iLat1;
Long1=iLong1;
Lat2=iLat2;
Long2=iLong2;
Lat3=iLat3;
Long3=iLong3;
}
multimap<double,double> dic;//initialization
dic.insert(pair<double,double>(2,gcnew siteNEVObjectdic(Lat1,Long1,Lat2,Long2,Lat3,Long3));
for some reason it is,
error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
giving me this error. any help will be appreciated.
You're creating a pair but trying to push a siteNEVObjectdic object in as the second entry. Try,
multimap<double,siteNEVObjectdic> dic;//initialization
dic.insert(pair<double,siteNEVObjectdic>(2,siteNEVObjectdic(Lat1,Long1,Lat2,Long2,Lat3,Long3));
Related
I want to take the modulus of a value when using Impala and I am aware of the abs() function. When I use this however like such
select abs(value) from table
It returns a value that is rounded to the nearest integer. The documentation found here states that I need to define the numeric_type. have tried this
select abs(float value) from table
but this gives me the following error
AnalysisException: Syntax error in line 1: ... abs(float value) from table ^ Encountered: FLOAT Expected: ALL, CASE, CAST, DEFAULT, DISTINCT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error
Any ideas how I set abs() to return a float?
This should work SELECT cast(Abs(-243.5) as float) AS AbsNum
I think you are misunderstanding the syntax. You call the function as abs(val). The return type is the same as the input type. It should work on integers, decimals, and floats.
If you want a particular type being returned, then you need to pass in that type, perhaps casting to the specific type.
The documentation is:
abs(numeric_type a)
Purpose: Returns the absolute value of the argument.
Return type: Same as the input value
Admittedly, this does look like the type should be part of the function call. But it is really using a programming language-style declaration to show the types that are expected.
I am a new Objective-C programmer and I am working on a project.
I created a function which returns a float value and I declared some variables into it as shown here :
-(float)WN8Calculation{
int avgDAMAGE,avgFRAGS,avgSPOT,avgDEF,avgWIN;
long battles;
double expDAMAGE,expFRAGS,expSPOT,expDEF,expWIN;
double rDAMAGE,rFRAG,rSPOT,rDEF,rWIN;
float rDAMAGEc,rFRAGc,rSPOTc,rDEFc,rWINc;
float wn8;
int tank_id;
avgDAMAGE =2;
return wn8;
}
When I assign the value for the variable avgDAMAGE I get an error in that line saying "expected expression". Can someone help?
Well i solved this error (i guess) what i had to do is to just delete the line a rewrite it..
Thanks for your help guys.
Question: Can I assume that Str(myString) will always return the same result as Str(CDbl(myString)) (assuming that myString is statically typed as a string)?
Context:
I am trying to understand VBA's implicit conversions. So far, it appears to me that Str(myString)
implicitly parses myString into a double (culture-sensitive) and then
converts the result into a culture-insensitive string.
For example, using a German locale (i.e. using , as the decimal separator), it holds that
" 1.2" = Str(1.2) = Str("1,2") = Str(CDbl("1,2"))
Since these implicit conversions contain a lot of "magic" to me, I am trying to rewrite a procedure that uses an implicit conversion (Str(myString)) to one using explicit conversion without changing the behavior.
Unfortunately, the documentation is wrong and, thus, useless. (The documentation claims that the argument to Str is interpreted as a Long, which is obviously rubbish: If that were the case Str(1.2) could never yield " 1.2".)
Your statement is true. Str(x) and Str(Cdbl(x)) give identical result provided that x is String data type and contains a valid number.
I made a small test to get convinced.
I used Excel, but it holds the same with Access.
Public Function myStr(txt As String) As String
myStr = Str(txt)
End Function
Public Function myStrCDbl(txt As String) As String
myStrCDbl = Str(CDbl(txt))
End Function
I tried with some key values (0, 1.2, 1E+307, 1E-307, ...) : result of myStr and myStrCDbl are always identical.
I also agree with you that the documentation is wrong. If Str() argument would be interpreted as Long, then Str(1.2) would give "1", because Long is an integer type.
In the mean time, I've found the VBA language specification and can confirm that the spec also answers the question with "yes":
CDbl, when receiving a string, performs a Let-coercion to Double:
If the value of Expression is not an Error data value return the Double data value that is the result of Expression being Let-coerced to Double.
Str, when receiving a string, first performs a Let-coercion to Double and then applies Str:
[If Number is a String,] the returned value is the result of the Str function applied to the result of Let-coercing Number to Double.
Public Sub MyFunction()
Dim lowstring As String
lowstring = "hi"
Me.RichTextView.Find(lowstring, 0, 2)
End Sub
The above produces the error of
Overload resolution failed because no accessible 'Find' can be called without a narrowing conversion:
Public Function Find(characterSet() As Char,
start As Integer, end As Integer) As Integer:
Argument matching parameter 'characterSet' narrows
from 'String' to '1-dimensional array of Char'.
Public Function Find(str As String, start As Integer,
options As System.Windows.Forms.RichTextBoxFinds) As Integer:
Argument matching parameter 'options' narrows from 'Integer' to
'System.Windows.Forms.RichTextBoxFinds'.
The error doesn't occur if you change the replacement string value, only if you change the second or third values to something other than 0.
Why doesn't the use of standard integers work here? What does this error really mean? Can anyone point me to some documentation for handling overloaded functions in vb.net (2010)?
I hope this question is focused enough... I've just been pretty confused about this one.
Thanks for any help - EB
As you can see, RichTextBox.Find has 7 overloads.
The one you're calling with 3 arguments and two integers takes a Char[] as first parameter, not a String.
This overload is used when you want to find the first instance of a character from a list of characters.
I assume that you want to find the position of your string in a given range. Then you need to use this overload: RichTextBox.Find(String, Int32, Int32, RichTextBoxFinds).
For example:
' Obtain the location of the search string in RichTextView'
Dim index = RichTextView.Find(lowstring, 0, 2, RichTextBoxFinds.WholeWord)
Note that you can combine different RichTextBoxFinds bitwise.
For example:
Dim index = Me.RichTextView.Find(
lowstring,
0,
2,
RichTextBoxFinds.WholeWord Or RichTextBoxFinds.MatchCase
)
Your function call does not match any of the overloads exactly. However, VB was kind enough to find two possible matches that would work if an argument you provided was casted to a different type.
You probably wanted the overload with the string parameter. So you should have written,
RichTextBox1.Find(lowstring, 0, RichTextBoxFinds.WholeWord)
The fact that RichTextBoxFinds.WholeWord happens to have numeric value of 2 is not a reason to use that value instead of the enum member name.
This would also work:
RichTextBox1.Find(lowstring, 0, CType(2, RichTextBoxFinds))
but it is stupid.
I'm taking a computer sciences class and we have to make a calculator using a GUI. I have been banging my head into a wall trying to even get input though.
Understand how to use pointers and GetValue(), to take in the input as a wxString but that does me no good, If I can't get the string as a double or integer then I can't perform operations on it.
Does anyone know how to convert wxString to Double? or even int?
Thanks in Advance
For this purpose, there are the two functions ToDouble and ToLong.
For details take a look at the offical documentation:
http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringtolong
http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringtodouble
EDIT: Example:
wxTextCtrl ctrl;
// user has entered a number
double number;
if( !ctrl.GetValue().ToDouble( &number ) )
// handle error
else
// continue...
Please note: It will only work if you enter a number. If you enter a term like 2+3 the function should return false. In this case you have to split the string up and interpret all numbers seperately.