![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | givenmnisi6 |
I get this error: Integer division, decimal part will be discarded
Here is the code: loads(totalVerse / 3 + 2)
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | givenmnisi6 |
I get this error: Integer division, decimal part will be discarded
Here is the code: loads(totalVerse / 3 + 2)
![]() |
Reply From: | jgodfrey |
If both values in the division are integers, the result will also be an integer. So, for example, this:
print(7 / 3)
…will result in the value 2
(the integer portion of the expected result). If you want to ensure floating point division, at least one value in the division needs to be a float. You can do that in a number of ways, including any of:
print(7.0 / 3)
print(7 / 3.0)
print(7.0 / 3.0)
print(float(7) / 3)
All of the above will produce the expected result of 2.33333...
as I’ve forced (at least) one value to be a float (in a few different ways)…
Also note, this is not an ERROR. It’s just a warning for your awareness. If you WANT integer division, than this is perfectly OK.
jgodfrey | 2023-06-20 21:33
Okay thank you so much
givenmnisi6 | 2023-06-21 12:28