0

I need help. I don't understand why it prints 0 instead of float number. Should i maybe use double?

https://code.sololearn.com/c7kJLoWzWw0j/?ref=app

10th Jun 2022, 10:18 AM
Jan Wantusiak
7 Antworten
+ 2
You can change the 180 to 180.00. None of your numbers are decimals so the wynik is not registering properly as a float (same for double).
10th Jun 2022, 10:27 AM
Justice
Justice - avatar
+ 1
Justice I think in python he can do 180/7 or whatever, he doesn't have to do a type conversion or add negative decimal places to do the deed. Nice to get a glimpse of the differences in other languages beforehand. I guess the huge difference awaiting getting used to is var declaration in other lang's
10th Jun 2022, 2:35 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
Korkunç the Terrible Frusciante Yeah, Python is an exception. But it also raises problem with python especially when unit testing and making sure to use correct variable types. Because if you then later wanted to convert the float without the decimals (so a float), you have to remember to convert it yourself rather than it automatically bring done at runtime.
10th Jun 2022, 2:51 PM
Justice
Justice - avatar
0
Whenever you want to use a float or double, you have to make on of the values a decimal number even if it's just adding .00 . This is true for most programming languages.
10th Jun 2022, 10:20 AM
Justice
Justice - avatar
0
So before the whole equation i have to add value to variable wynik?
10th Jun 2022, 10:25 AM
Jan Wantusiak
0
OMG thanks that works XD
10th Jun 2022, 10:28 AM
Jan Wantusiak
0
Glad to help. 😁
10th Jun 2022, 10:33 AM
Justice
Justice - avatar