|
KaKa` wrote: There was an error message about the power function when I compiled the code. It is: error c2668: 'pow' :ambiguous call to overloaded function.
Apparently there's more than one pow() function. Which one do you want to use?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how is defined the data matrix (what type) ?
i think it contains values other than int , that's why the compiler doesn't know which function to call (pow(int, int) or pow(double, double) ?? ).
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I'm thinking that it could have something to do with your data types... are all your variables "int", or are you mixing types?
Patrick
|
|
|
|
|
If you couldn't figure out the problem, why don't you write your own pow() function? It's simple...
|
|
|
|
|
cppcook wrote: If you couldn't figure out the problem, why don't you write your own pow() function? It's simple...
Simple for integer exponents ... not so simple for decimal exponents.
As for the original post, my guess is that you are mixing types (that is, raising a double by an integer power). While there is nothing wrong with that, pow is usually defined:
From MSDN:
double pow(
double x,
double y
);
double pow(
double x,
int y
);
double pow(
int x,
int y
);
float pow(
float x,
float y
);
float pow(
float x,
int y
);
long double pow(
long double x,
long double y
);
long double pow(
long double x,
int y
);
float powf(
float x,
float y
);
Try explicitly casting your types:
double base = 3.0;
int power = 5;
int result = pow(base, (double)power);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Is a result of implicit casts being available. Explicitly case each parameter to the datatype to use that matches one of the pow formal parameter lists.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
If you know nothing about function overloading just cast both parameters to (double) and it will compile.
tempDistance += pow(((double)data[selectedInstance][k]-data[j][k]),2.0);
|
|
|
|
|
Thanks all for the replies.......i used the simple way and cast both parameters to double and it can work now.
|
|
|
|
|
Hi everyone,
I have an Edit box in a dialog with multiline property and four scroll bar properties checked. A text file is read into the edit box. The file is tab spaced structured data file (40 rows, but with thousands of columns). The problem is the edit box will break the row in the original file into several rows and display it. This makes the data looks unstructured and disordered. I know this is because the row is too long so the Edit box wraps words automatically. But can we avoid this?
thanks,
gavin
|
|
|
|
|
Does the WS_HSCROLL style help?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David,
I checked all the four scroll properties, Horizontal scroll, Auto Hscroll, Vertical Scroll, Auto Vscroll. But it didn't help.
Gavin
|
|
|
|
|
Does your text happen to have any embedded CR OR LF characters in it? I just tried this by entering a long line of text into a narrow edit control and it scrolled vertically until I hit Enter.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes. The text file has newline characters in it. The edit box will jump to a new line after a limited length of characters even if it doesn't meet a CR or LF character. While this is not what I want. thanks anyway.
gavin
|
|
|
|
|
|
Looking at this syntax, I can't quite see what the end result should be. What does this function return?
long comm_fm_node_id(comm_fm_dev_t *dev, long group) {
return (group == 0) ? MCAST_nodeid : -1;
}
Patrick
|
|
|
|
|
if(group == 0)
return MCAST_nodeid;
else
return -1;
|
|
|
|
|
it means :
long comm_fm_node_id(comm_fm_dev_t *dev, long group) {
if (group == 0) {
return MCAST_nodeid;
}
else {
return -1;
}
}
but i really don't see what dev is passed to the function if it doesn't use it, and i suspect MCAST_nodeid to be a global variable...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Dev isn't used because it's only a partial implementation... I'm trying to finish the implementation...
Thanks for your help.
Patrick
|
|
|
|
|
pgav wrote: long comm_fm_node_id(comm_fm_dev_t *dev, long group) {
return (group == 0) ? MCAST_nodeid : -1;
}
By the way, be VERY judicious when using the ternary operator (which is what the expression ? result_if_true : result_if_false is called). Most of the time, it is far more clear to write:
if (expression)
{
return SomeValue;
}
else
{
return SomeOtherValue;
}
I can't tell you how many bugs I've run into because people tried to get fancy with the ternary operator and do things like:
return expression1 ? expression2 ? expression4 ? 1 : 0 : 3 : expression3 ? 2 : 4;
If you run into something like that, you should hunt down the person who wrote it, take them out behind your office, and ... well, you get the idea.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
Is any one aware of a technique of easily putting a breakpoint in every function in a solution (MSDev.Net 2003).
I'm currently having to make some modifications to the Firebird 1.5 source code and finding where it is called when a user calls connection.setAutoCommit(false); from a Java Servlet is turning out quite time consuming.
Thanks
Tom
|
|
|
|
|
Hey guys,
Im working with winsocket in one of my projects and I have some questions regarding Windows Sockets. I see that it is used to send data over the TCP/ IP network protocol but why is it specifically called Windows socket? If I try running two different simulations which interact with one another over a network, do both of the simulations have to be running on the WINDOWS OPERATING SYSTEM? If anyone has any links that can give me the basic understanding of what goes on in the Windows Socket it would be greatly appreciated
Thanks,
Jay
|
|
|
|
|
WinSock is just the library name. It is basically Microsoft's implementation of the Berkeley sockets that are used on *Nix systems. From a development point of view, there is very little different in the way of method calls, arguments, etc (outside of initializing and freeing the library). When using it, you can communicate with anything that talks TCP/IP, regardless of the OS. Just make sure you keep byte-ordering in mind when programming.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Jay03 wrote: If I try running two different simulations which interact with one another over a network, do both of the simulations have to be running on the WINDOWS OPERATING SYSTEM?
No. That's the beauty of TCP. Neither end has to be concerned with the other (e.g., Windows <-> Unix <-> OS/400). They just both have to speak the same language. This is a somewhat simplified explanation. See here for more on TCP. See here for more on the OSI model.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
TCP doesn't inherently care about different architectures, but some care (see ntohl and htonl) has to be taken to make sure that the data you send (you just hand the functions a hunk of memory) isn't architecture / OS dependent.
earl
|
|
|
|
|
Great answers guys....... thanks a lot!
|
|
|
|