0

why do you convert to a double a string value = "77" instead of an int?

15th Aug 2016, 4:03 AM
Lezly Rodríguez D
Lezly Rodríguez D - avatar
7 Respuestas
+ 1
thanks :)
15th Aug 2016, 5:41 AM
Lezly Rodríguez D
Lezly Rodríguez D - avatar
0
When I need double - I convert to double. Simple.
15th Aug 2016, 5:12 AM
Ivan G
Ivan G - avatar
0
it's because on the exercise it converts it to double and since the number has no point that' s why I was asking , It is supposed to be an int right?
15th Aug 2016, 5:20 AM
Lezly Rodríguez D
Lezly Rodríguez D - avatar
0
It depends on variable which will store your converted value. If it is int - convert to int. If it is double - convert to double. When you parse user input (a string) if you decide to use double for variable (because of some requirement for it in your program logic) then you should obviously convert it to double. Otherwise if your program logic is okay with integer, then your variable and convert operation should be for integer.
15th Aug 2016, 5:38 AM
Ivan G
Ivan G - avatar
0
@ivan. sry i still don't undrstnd, is there any major difference between int and double?
18th Aug 2016, 2:45 AM
Bagas Jamall
Bagas Jamall - avatar
0
How do I make a block of code unseen or unreadable by my program?
19th Aug 2016, 3:09 PM
Daniel Ofori
Daniel Ofori - avatar
0
@Bagas, major difference is that double is a floating point number datatype (with decimals)
19th Aug 2016, 10:04 PM
Ivan G
Ivan G - avatar