Skip to content

Add PrecisionFromFloat32() to return precision without performing conversion #3

@x448

Description

@x448

It would be useful to know the precision of converting IEEE binary32 to binary16, if the function can be inlined.

PrecisionFromFloat32 should return Precision without performing the conversion.
Conversions from both Infinity and NaN values will always report PrecisionExact even
if NaN payload or NaN-Quiet-Bit is lost.

If this is too complex to be inlined by Go, then make it an extra return value as part of conversion functions.

// Precision indicates whether the conversion to Float16 is
// exact, inexact, underflow, or overflow.
type Precision int

const (
       PrecisionExact Precision = iota
       PrecisionInexact
       PrecisionUnderflow
       PrecisionOverflow
)

func PrecisionFromfloat32(f32 float32) Precision 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions