+ 1

What if we want the quotient and remainder of divide to be float? // And % doesn't give it in float form....

QUOTIENT IN FLOAT

28th Dec 2017, 12:52 PM
LEO
LEO - avatar
2 odpowiedzi
+ 3
You can python ask to return a number as a float by using float() The output of print(float(10%3)) is 1.0
28th Dec 2017, 1:14 PM
Sebastian Keßler
Sebastian Keßler - avatar
+ 1
Depends on the language. But in general there are two options. If you want to calculate an integer A modulo an integer B, then the integer division // and modulo will return integers. These integers can be type casted to float. Secondary, if you want to calculate a float A modulo a float B/Integer B, the integer division and the modulo operator will not work. @Sebastian This is the same you suggested, but I kept the concept of Type Casts more in general. But you did a good example at this point.
28th Dec 2017, 1:51 PM
Andreas K
Andreas K - avatar