0
why do you convert to a double a string value = "77" instead of an int?
7 Answers
+ 1
thanks :)
0
When I need double - I convert to double. Simple.
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?
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.
0
@ivan. sry i still don't undrstnd, is there any major difference between int and double?
0
How do I make a block of code unseen or unreadable by my program?
0
@Bagas, major difference is that double is a floating point number datatype (with decimals)