How can i convert to float or integer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i convert to float or integer?

2nd Dec 2016, 6:28 PM
Joseph Ogedengbe
Joseph Ogedengbe - avatar
5 Answers
+ 6
x = 6.00; y = int(x); // y now references the value 6 not 6.0
2nd Dec 2016, 6:35 PM
NICKALL [EP]
NICKALL [EP] - avatar
+ 1
Just declare the typecast variable again as an int('•••••••. ') I hope that would make U out.
3rd Jan 2017, 9:02 AM
Devaashish Sharma
0
typecast it..
2nd Dec 2016, 11:40 PM
Rahul Sharma
Rahul Sharma - avatar
0
float() converts integers to floats for example: x=9.0 x=float(x) print(x) output: 9
8th Dec 2016, 4:36 PM
dan
dan - avatar
- 2
Simple: int x = Math.round(float)
2nd Dec 2016, 7:26 PM
M.I.Rayhan
M.I.Rayhan - avatar