+ 5

Can someone explain what's the difference between 7.0 and 7?

For examle 7.0/2+3.5 and 7/2+3.5 why is this giving different values?

5th Jul 2019, 9:01 PM
Lily
Lily - avatar
10 Answers
+ 13
Using dot you say to program that its a float number so he will keep numbers after dot as well ( 7.0/2 = 3.5) otherwise he is working with an integer so (7/2 = 3) =)
5th Jul 2019, 9:19 PM
Krysto Foxik đŸ„
Krysto Foxik đŸ„ - avatar
+ 5
🍕🍕 Felix Gautsch after visual studio 17 its necessary to write f
8th Jul 2019, 5:40 PM
Krysto Foxik đŸ„
Krysto Foxik đŸ„ - avatar
+ 3
7.0 is a float number, whereas 7 is a decimal number. Your output type would be same as your input type: 7.0 / 2 = 3.5 7 / 2.0 = 3.5 7.0 / 2.0 = 3.5 7/2 = 3
5th Jul 2019, 9:53 PM
Mohsen Khodadadi
Mohsen Khodadadi - avatar
+ 2
Can you share the code with us ?
5th Jul 2019, 9:24 PM
sneeze
sneeze - avatar
+ 2
Data types - the first is float and the second is intđŸ€—
6th Jul 2019, 7:02 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
Whenever u see a decimal point then it's a float and returns value in float.. Without decimal point is integer
6th Jul 2019, 7:08 PM
Dheeraj
Dheeraj - avatar
+ 2
Krysto Foxik đŸ„ Using dot means that it's a *double*, not a *int* or float value.. with an f, it's a float value, for example 7.0f đŸ‘ŒđŸ»
8th Jul 2019, 5:02 PM
Felix Gautsch 🍕
Felix Gautsch 🍕 - avatar
+ 1
can you share the code đŸ€”đŸ€”
6th Jul 2019, 11:22 AM
Zenati Anfal Yasmine
+ 1
My question would be: Is it bad I usually ignore the format of a number/word/text/whatever? (as in float or integer etc...)
6th Jul 2019, 4:53 PM
???
??? - avatar
+ 1
The difference is between the data type. '7' is an int, but '7.0' can be float or decimal.
15th Jul 2019, 7:37 AM
Keivan Ipchi
Keivan Ipchi - avatar