jax-ml / jax-ml/ml_dtypes

[Question / possible bug] When `Saturate = false`, underflow gives `nan` but overflow gives `inf`; is this standard? What's the use?

Open
#291 3 comments 0 reactions 1 assignee Claimed by @jakevdp View on GitHub
Dominant language
C++
Stars
361
Forks
60
Avg merge
18h 41m
Merged PRs (30d)
3

Description

### Examples of underflow (or subnormal) = `nan`
https://github.com/jax-ml/ml_dtypes/blob/1527272ef82990434e637c1545c8ae93141b43f1/ml_dtypes/include/float8.h#L1423-L1431
https://github.com/jax-ml/ml_dtypes/blob/1527272ef82990434e637c1545c8ae93141b43f1/ml_dtypes/include/float8.h#L1433-L1438

### Examples of overflow = `inf`
https://github.com/jax-ml/ml_dtypes/blob/1527272ef82990434e637c1545c8ae93141b43f1/ml_dtypes/include/float8.h#L1562-L1572

### Expected results
Both `nan`, or both `inf`.

### `nan` > `inf`
https://github.com/jax-ml/ml_dtypes/blob/1527272ef82990434e637c1545c8ae93141b43f1/ml_dtypes/include/float8.h#L1103-L1105
https://github.com/jax-ml/ml_dtypes/blob/1527272ef82990434e637c1545c8ae93141b43f1/ml_dtypes/include/float8.h#L1111-L1113

So it is confusing to use `nan` for lower values.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.