I don't understand. I know Soma said that too, but I didn't have to provide arguments of the same type when ftype was defined as float, since I provided it with a float and an int and it worked....
Type: Posts; User: then
I don't understand. I know Soma said that too, but I didn't have to provide arguments of the same type when ftype was defined as float, since I provided it with a float and an int and it worked....
I tried your class, iMalc, and everything seems to work like it does for floats or doubles, except from the ?: operator, just like for the class I defined.
Also, I had to change the return value...
phantomotap, I appreciate your support and you might be right about what you say, but if you want to help people you can't start by offending them.
Thanks, it looks great. I haven't got time...
So you should have an opinion that is relevant but not me? And I don't know what it was I wrote that you think is wrong. It is easy to just ignore the rest of what you are writing when you start your...
It would be interesting to see your implementation and if it differs something from my class (except from that my isn't finished yet).
I don't get this error when f just is a normal float, that is why a base_safe_float<float> shouldn't generate any error here either.
Okay. I have already started to write the other operators...
Doesn't the compiler realize that it can just use the conversion operator and then compare a float against whatever it is I want to compare it against?
I'm trying. So far I the class declaration looks like this:
template<typename T>
class base_safe_float
{
public:
/* Constructors */
base_safe_float(); // Default constructor
Thank you, that is one way to generate a NaN, yes. But the question was how to make the kind of class I described above.
Hi! I want to make a class that works exactly like a float, only that it is initialized to NaN when the default constructor is called and if DEBUG is defined so that I can easily detect when I have...
Ah, okay, that makes sense. Well, thanks for the answers.
> "The expression that controls conditional inclusion"
I don't want to conditionally include a file, I just want to select between two snippets of code. But I take it all preprocessor conditions...
Hi, if define A as
#define A 100
and write
Okay, thanks for the answer. I think I will just define the function explicitly for all types I am going to use it for, since it rather small, and skip the template.
Simply because it's simpler to write foo(0, 0.5) :P If I define foo as
double foo(double a, double b)
{
return a + b;
}
then foo(0, 0.5) compiles, so I want it to compile even for my...
I wonder how to solve a problem that I have with a template function. The function definition looks like
template<typename T>
T foo(T a, T b)
{
return a + b;
}
but this produces an...
Agreed. You might be especially right with the last part because our program doesn't even work yet! Thanks for getting me on the right track.
It was just a very simple example. In my case the variable is of course not called ONE, but is a parameter used in a simulation program. If SI units are used, this parameter will not be one and it...
Okay, thanks for being more clear. This other guy, has he successfully made it in this way? If not, this method seems highly unlikely to succeed if it's not known to work for this game. You seem to...
Ehm, yeah it's out of our fields right, that's why we can't help you. Have you considered that the reason we can't help you is because you have only been speaking gibberish? It should be pretty clear...
rand() % 100 will give you a number between 0 and 99. To do something with num_percent percent chance, use the following:
if (rand() % 100 < num_percent) {
// Do something
}
else {
...
What are you talking about?? To begin with; what is your question? I did not see any question in your post. You are playing a game, okay, but – upgrading your gear; what gear? Linking items in it;...
Learn C++ and it should be a simple matter. I don't think there exists any tool that converts MatLab code to C++, partly because it would depend much on the way the code is supposed to be...
Does mingw optimize multiplication/division by one? That is, if I write
ONE * a
or
a * ONE
or