Python loop function behavior when inputs are of type np.float64

I find it rather strange that the round python function returns numpy.float64 when the input file is numpy.float64 , but returns int when input is float . Example:

from numpy import float64
type(round(float64(3243.43)))
>>> numpy.float64
type(round(float(3243.43)))
>>> int

Why does round return numpy.float64 and not int in the first line?

Note: I am using: Python 3.5.1 [MSC v.1900 64 bit (AMD64)]

+4
source share
1 answer

When the argument is not Python floating, there is a difference in behavior between Python 2 and 3.

Python 2.x, round() float. Python 3.x, round() __round__. __round__ . , int, int.

math.ceil, math.floor math.trunc. __ceil__, __floor__ __trunc__.

. PEP 3141

+5

All Articles