Hi,

i am using pow command quite frequently in my codes, and i have a feeling that i may be using it incorrectly.
foe ex:

pow(image[x][y],2);

image[x][y] is unsigned char and 2 is numeric, so is the arguments ok.

std_dev=pow(((ur_mean/(R*C))-(im_mean*im_mean)),.5);

this a bit complicated, will it work this way?
is it not a problem if the data types of the POW arguments are different.

:?:

Put some really obvious parameters in (like make an element of image[x][y] = 4 and the result should be 2) and check the results? if it compiles that is the only way to check that the output is correct

All function defined in math.h takes argument as datatype double .....ur code is perfectly alrite ..... if u use pow('a',2) it will take the ASCII value of a which is 97 and it will display 97*97 = 9409 by using this code printf("%f",pow('a',2)) ..... u can also get the input from the user as far as characters are concerned

>it will take the ASCII value of a which is 97
We don't care whether you know what the integer values of the ASCII characters are. Stop assuming a specific character set. Geez, how many times do I have to repeat myself before you people get a clue?

All function defined in math.h takes argument as datatype double .....ur code is perfectly alrite ..... if u use pow('a',2) it will take the ASCII value of a which is 97 and it will display 97*97 = 9409 by using this code printf("%f",pow('a',2)) ..... u can also get the input from the user as far as characters are concerned

thanks , i got the idea.

>it will take the ASCII value of a which is 97
We don't care whether you know what the integer values of the ASCII characters are. Stop assuming a specific character set. Geez, how many times do I have to repeat myself before you people get a clue?

And NOW we have you Narue.
IF ASCII is explicitly referred to it will ALWAYS be the same because ASCII is a well defined set of characters and codes.
It stands for American Standard Code for Information Interchange.

If Any other character set is referred to you're theoretically correct (though many will include ASCII as the lower 127 characters).

>And NOW we have you Narue.
No, you just think you do because you're making the same mistake.

>IF ASCII is explicitly referred to it will ALWAYS be the same
Yes.

>because ASCII is a well defined set of characters and codes.
Yes.

>It stands for American Standard Code for Information Interchange.
Yes.

>If Any other character set is referred to you're theoretically correct
C++ doesn't define the integral values of the basic character set, so saying that 'a' is equivalent to 97 is wrong. Even if you qualify that as the ASCII value 97, it's still wrong because the C++ uses the native character set of the machine on which it's running. If the machine uses another character set, such as EBCDIC, 'a' certainly won't be ASCII, nor will its integral value be 97. So your argument falls flat.

When the OP makes it very clear that their character set is ASCII, I don't have a problem. But this is a case of making an unwarranted assumption (no matter how likely it may be) out of either laziness or ignorance.

To summarize: Even though ASCII is a well defined and standardized character set, it's not the only one out there. C++ caters to everyone, so assuming that everyone uses ASCII will bite you eventually.

This question has already been answered. Start a new discussion instead.