You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while I would expect it to return array([19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613.], dtype=float32)
The text was updated successfully, but these errors were encountered:
The integer 19211613 cannot be represented exactly as a single precision (32 bit) floating point value. At that magnitude, the spacing between representable values is 2.
In [16]: np.float32(19211613)
Out[16]: np.float32(19211612.0)
In [17]: x = np.float32(19211613)
In [18]: np.spacing(x)
Out[18]: np.float32(2.0)
2.0
In [19]: np.nextafter(x, np.float32(np.inf))
Out[19]: np.float32(19211614.0)
I was expecting something about the machine precision, but I could not find an answer and was just verifying that the value was below the maximum value we could represent. Thank you very much for the clarification!
Describe the issue:
For some cases, when we use
np.full
with a fill_value that is an integer and withdtype=np.float32
, we get a result off by 1.Reproduce the code example:
Error message:
No response
Python and NumPy Versions:
1.26.4
3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]
Runtime Environment:
[{'numpy_version': '1.26.4',
'python': '3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) '
'[GCC 12.3.0]',
'uname': uname_result(system='Linux', node='bbelucci-gs75', release='6.8.0-40-generic', version='#40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL',
'AVX512_SPR']}},
{'filepath': '.../lib/libmkl_rt.so.2',
'internal_api': 'mkl',
'num_threads': 6,
'prefix': 'libmkl_rt',
'threading_layer': 'intel',
'user_api': 'blas',
'version': '2022.1-Product'},
{'filepath': '.../lib/libomp.so',
'internal_api': 'openmp',
'num_threads': 12,
'prefix': 'libomp',
'user_api': 'openmp',
'version': None}]
Context for the issue:
The code returns
array([19211612., 19211612., 19211612., 19211612., 19211612., 19211612., 19211612., 19211612., 19211612., 19211612.], dtype=float32)
while I would expect it to return
array([19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613., 19211613.], dtype=float32)
The text was updated successfully, but these errors were encountered: