Is this related to how the number is stored in memory?Endianness refers to the sequential order in which bytes are arranged into larger numerical values, when stored in computer memory or secondary storage, or when transmitted over digital links. Endianness is of interest in computer science because two conflicting and incompatible formats are in common use: words may be represented in big-endian or little-endian format, depending on whether bits or bytes or other components are ordered from the big end (most significant bit) or the little end (least significant bit).>>> import numpy as np
>>> a = np.array([1, 2, 3, 4], dtype='>i4')
>>> a.view('int8')
array([0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4], dtype=int8)
>>> a = np.array([1, 2, 3, 4], dtype='
>>> a.view('int8')
array([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0], dtype=int8)
如果没有,它将使用系统的endianness。使用另一个可能会导致(轻微)性能下降。在
最后
以上就是无心帽子最近收集整理的关于python int32 int8_用numpy vi将int32转换为int8的全部内容,更多相关python内容请搜索靠谱客的其他文章。
发表评论 取消回复