About 299,000 results
Open links in new tab
  1. python - Why should I use ints instead of floats? - Stack Overflow

    Dec 8, 2013 · The first point is trivially true, but it misleadingly implies that ints are smaller than floats (the size depends on the exact int and float types, which for Python's built in types depends on the …

  2. math - `/` vs `//` for division in Python - Stack Overflow

    In Python 3.x, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the latter is floor division, sometimes also called integer division. In Python 2.2 or later in the 2.x line, …

  3. int() vs float() inputs in Python 3 and their utility?

    Dec 6, 2015 · If it needs to accept both integers and floats as inputs, then you should convert to float since floats can represent the integers. But if you're program requires that the input be specifically an …

  4. How does Python compare 'int' to 'float' objects? - Stack Overflow

    Jan 31, 2020 · If I recall correctly, Python, or at least some implementations of it, goes to pains to compare values exactly. When 3**64 is compared to float(n), it is not converted to float. Rather, the …

  5. python - Why does integer division yield a float instead of another ...

    I understand the reason why Python does it in the instances of the answer not being #.0, but not for instances where the answer is #.0. Float 1.0 is the same as integer 1, so when the numbers being …

  6. Comparing a float and an int in Python - Stack Overflow

    Apr 5, 2012 · Here distance would effectively return a float and radius is an int. I do know that I should not compare floats directly and that I should compare with a threshold. Given that, is there a better …

  7. Memory usage of Python base types (particulary int and float)

    Dec 15, 2019 · In short, it all boils down to how Python represents arbitrary long integers. float() types are represented (limited) just as C double. In CPython implementation, every object (source) begins …

  8. python difference between round and int - Stack Overflow

    Apr 27, 2017 · 59 Note: The python implementation changed between 2.7 and 3.x. I corrected the answer accordingly. For the sake of completeness, let me add two more functions to your question …

  9. What is the difference between int() and floor() in Python 3?

    Rounding down can be done in many ways, some methods are equivalent, e.g. built-in int, numpy.trunc and numpy.fix which truncate the number, meaning for a negative number they return a result which …

  10. python - what is the difference between "eval" and "int" - Stack Overflow

    Advice: use int, because it's safer, doesn't have security issues (eval can evaluate any expression, including system calls and file deletion), and suits your purpose perfectly. Note: the above code is …