|
| 1 | +# Data type functions |
| 2 | + |
| 3 | +> Array API specification for data type functions. |
| 4 | +
|
| 5 | +A conforming implementation of the array API standard must provide and support the following data type functions. |
| 6 | + |
| 7 | +<!-- NOTE: please keep the constants in alphabetical order --> |
| 8 | + |
| 9 | +## Objects in API |
| 10 | + |
| 11 | +(finfo)= |
| 12 | +### finfo(type, /) |
| 13 | + |
| 14 | +Machine limits for floating-point data types. |
| 15 | + |
| 16 | +#### Parameters |
| 17 | + |
| 18 | +- **type**: _Union\[ <dtype>, <array> ]_ |
| 19 | + |
| 20 | + - the kind of floating-point data-type about which to get information. |
| 21 | + |
| 22 | +#### Returns |
| 23 | + |
| 24 | +- **out**: _<class>_ |
| 25 | + |
| 26 | + - an object having the following attributes: |
| 27 | + |
| 28 | + - **bits**: _int_ |
| 29 | + - number of bits occupied by the floating-point data type. |
| 30 | + - **eps**: _float_ |
| 31 | + - difference between 1.0 and the next smallest representable floating-point number larger than 1.0 according to the IEEE-754 standard. |
| 32 | + - **max**: _float_ |
| 33 | + - largest representable number. |
| 34 | + - **min**: _float_ |
| 35 | + - smallest representable number. |
| 36 | + |
| 37 | +(iinfo)= |
| 38 | +### iinfo(type, /) |
| 39 | + |
| 40 | +Machine limits for integer data types. |
| 41 | + |
| 42 | +#### Parameters |
| 43 | + |
| 44 | +- **type**: _Union\[ <dtype>, <array> ]_ |
| 45 | + |
| 46 | + - the kind of integer data-type about which to get information. |
| 47 | + |
| 48 | +#### Returns |
| 49 | + |
| 50 | +- **out**: _<class>_ |
| 51 | + |
| 52 | + - a class with that encapsules the following attributes: |
| 53 | + |
| 54 | + - **bits**: _int_ |
| 55 | + - number of bits occupied by the type |
| 56 | + - **max**: _int_ |
| 57 | + - largest representable number. |
| 58 | + - **min**: _int_ |
| 59 | + - smallest representable number. |
| 60 | + |
| 61 | +(function-result_type)= |
| 62 | +### result_type(*arrays_and_dtypes) |
| 63 | + |
| 64 | +Returns the dtype that results from applying the type promotion rules |
| 65 | +(see {ref}`type-promotion`) to the arguments. |
| 66 | + |
| 67 | +```{note} |
| 68 | +If provided mixed dtypes (e.g., integer and floating-point), the returned dtype will be implementation-specific. |
| 69 | +``` |
| 70 | + |
| 71 | +#### Parameters |
| 72 | + |
| 73 | +- **arrays_and_dtypes**: _Sequence\[ Union\[ <array>, <dtype> \] \];_ |
| 74 | + |
| 75 | + - input arrays and dtypes. |
| 76 | + |
| 77 | +#### Returns |
| 78 | + |
| 79 | +- **out**: _<dtype>_ |
| 80 | + |
| 81 | + - the dtype resulting from an operation involving the input arrays and dtypes. |
0 commit comments