
- Forum
- Programming Talk
- C and C++
- Integer or Float... Not Clear!!!!!
Integer or Float... Not Clear!!!!!
This is a discussion on Integer or Float... Not Clear!!!!! within the C and C++ forums, part of the Programming Talk category; Hi All, I have an integer value and a float value and if I perform arithmetic operation between the values ...
-
Integer or Float... Not Clear!!!!!
Hi All,
I have an integer value and a float value and if I perform arithmetic operation between the values what would be the result? Will it be an integer value or a float value?
Regards,
Allan
-
Hi,
I have not thought of this operation which is very common occurrence in any mathematical calculation. So it is essential to know the answer for the same. I could not figure out the answer but while searching answer for this question one more related question cam to my mind and it is what would be the result of if we assign a float value to a integer what would be the result will it be a float or a integer? Someone answer the related question along with the previous one.
Regards,
Blenda
-
Hi,
I know that arithmetic operation between integer and integer results in integer and similarly arithmetic operation between float and float results in float. But this question is interesting and kindly someone let us know the answer for the same.
Regards,
Norman
-
Hi,
The answer for all the questions and queries posted in this section will help to get an insight on Integer and Float conversions and handling of numeric data types in C program. The answer to the first question is arithmetic operation between integers and float results in always float and the answer to the second question is assigning a float value to an integer gives an integer result.
Regards,
Norman
-
Hi,
Having known the answer from Norman if someone wants to get the explanation for the same read the following:
The arithmetic operation between integer and float results as always float because integer first gets converted into float and then operation is carried out. So operation between float and float results in always float. When a float value is assigned to a integer it is converted as integer because left side assignment variable is of type integer and hence result is a integer.
Regards,
Blenda
-
that will be float.if u r collecting thease value in a int then it ll be casted to int
Originally Posted by Allan
Hi All,
I have an integer value and a float value and if I perform arithmetic operation between the values what would be the result? Will it be an integer value or a float value?
Regards,
Allan
-
Hi,
But one thing that must be taken care is when float is casted into integer it losses data and so one must ensure the need of such a result.
Blenda
-
Sponsored Ads

Reply With Quote





