numpyfloating-pointprecision

Which float precision are NumPy arrays by default?


I wonder which format floats are in NumPy array by default. (or do they even get converted when declaring a np.array? if so how about python lists?) e.g. float16, float32, or float64?


Solution

  • If you dont specify the data type when you create the array then numpy will infer the type, from the docs

    dtypedata-type, optional - The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence