HHalfJunia
Product

Product features · Binary16 value decoding

01

HalfJunia helps review how exponent and fraction fields become binary16 values, with exceptional patterns distinguished from ordinary finite numbers.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Binary16 value decoding

● ● ●HalfJunia●
A concrete starting point · Binary16 value decoding ×
from math import copysign, ldexp

def binary16_value(word):
    if type(word) is not int or not 0 <= word <= 65535:
        raise ValueError("binary16.word")
    sign = -1.0 if word & 0x8000 else 1.0
    exponent, fraction = (word >> 10) & 31, word & 1023
    if exponent == 31:
        return copysign(float("nan") if fraction else float("inf"), sign)
    value = ldexp(fraction, -24) if exponent == 0 else ldexp(1024+fraction, exponent-25)
    return copysign(value, sign)
✳Decode one unsigned 16-bit binary16 word into a numeric value.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗