add float support to spec
This commit is contained in:
parent
db20fa813e
commit
7c93767cc8
3 changed files with 50 additions and 0 deletions
|
|
@ -645,6 +645,30 @@ Text/ASCII literals:
|
|||
- Useful for: magic numbers (`'ELF'`), protocol tags, inspecting
|
||||
how string bytes pack into integer registers
|
||||
|
||||
IEEE 754 float interpretation:
|
||||
- A sub-view within programmer mode (toggle with a key, e.g. Ctrl-F)
|
||||
- Reinterprets the current bit pattern as an IEEE 754 float
|
||||
- Supported formats:
|
||||
- float32 (1 sign + 8 exponent + 23 significand, bias 127)
|
||||
- float64 (1 sign + 11 exponent + 52 significand, bias 1023)
|
||||
- Bit grid color-codes the three fields:
|
||||
- Sign bit: one color (e.g. pink)
|
||||
- Exponent: another color (e.g. cyan)
|
||||
- Significand: another color (e.g. green)
|
||||
- Display below the bit grid shows:
|
||||
- Decimal value (exact)
|
||||
- Formula: (-1)^s * 2^(e-bias) * 1.mantissa
|
||||
- Classification: normal, denormal, zero, infinity, NaN
|
||||
- ULP: delta to next representable value
|
||||
- Raw fields: sign=0, exp=127 (unbiased: 0), frac=0x000000
|
||||
- Input: can type a decimal float value (e.g. `3.14`) and it
|
||||
shows the closest representable bit pattern, noting if rounding
|
||||
occurred
|
||||
- Toggling bits in the grid updates the float interpretation live
|
||||
- Does NOT change bit_width setting - float32 uses 32-bit view,
|
||||
float64 uses 64-bit view (auto-switches width when toggling
|
||||
float format)
|
||||
|
||||
### 8.3 Struct Visualizer (sub-view of Programmer Mode)
|
||||
```
|
||||
┌─ Tally ────────────────── [Programmer > Struct Layout] ─────────────┐
|
||||
|
|
|
|||
|
|
@ -31,6 +31,16 @@ A calculator application with three frontends (CLI, TUI, Android) sharing a comm
|
|||
- **FR-2.8**: Configurable endianness display (little-endian default, big-endian available). Affects byte order in HEX display and byte-level visualizations. Does not change the underlying value - purely a display/interpretation toggle.
|
||||
- **FR-2.9**: ASCII/text literal input via single-quoted strings: `'hello'` packs ASCII bytes into the integer value. First character occupies the most significant used byte (big-endian packing when display is BE) or least significant byte (when display is LE). Useful for examining magic numbers, file signatures, protocol headers.
|
||||
- **FR-2.10**: ASCII interpretation display - when the current value contains printable ASCII bytes, show the text representation alongside the numeric bases (e.g., `ASCII: "ELF."` or `ASCII: ..lf` with dots for non-printable bytes).
|
||||
- **FR-2.11**: IEEE 754 floating-point interpretation (float.exposed style):
|
||||
- Support float32 (single) and float64 (double) formats, selectable
|
||||
- Decompose bit pattern into sign bit, exponent field, and significand/mantissa field with visual color-coding in the bit grid
|
||||
- Display the evaluation formula: (-1)^sign * 2^(exponent - bias) * 1.mantissa
|
||||
- Display the exact decimal value represented by the bit pattern
|
||||
- Display delta to next and previous representable float (ULP - unit in last place)
|
||||
- Handle special values: +/-infinity, NaN, denormals/subnormals, +/-zero
|
||||
- Allow toggling individual bits and seeing the float value update in real-time
|
||||
- Allow entering a decimal float value and seeing the closest IEEE 754 representation
|
||||
- Show when a value is not exactly representable (rounding occurred)
|
||||
|
||||
### FR-3: Struct Layout Visualizer (Programmer Mode Extension)
|
||||
|
||||
|
|
|
|||
|
|
@ -267,6 +267,22 @@ Subcommands deferred until Phase 2 engine work is done.
|
|||
- 128-bit width also added (u64 -> u128 throughout engine)
|
||||
- Verify: `'A'` = 0x41, `'ELF'` = 0x454C46, overflow on too-long strings
|
||||
|
||||
### Task 5.3.3: Implement IEEE 754 float interpretation [NOT STARTED]
|
||||
- Add float interpretation engine module (`engine/src/float_interp.zig`)
|
||||
- Given a u32 or u64 bit pattern, decompose into sign, exponent, significand
|
||||
- Compute exact decimal value (including denormals, infinities, NaN)
|
||||
- Compute ULP (delta to next/previous representable value)
|
||||
- Classify: normal, denormal, zero, +inf, -inf, quiet NaN, signaling NaN
|
||||
- Given a decimal float, find the closest IEEE 754 bit pattern and report rounding
|
||||
- TUI sub-view (Ctrl-F toggles float interpretation overlay in programmer mode):
|
||||
- Color-coded bit grid (sign=pink, exponent=cyan, significand=green)
|
||||
- Formula display, classification, ULP, exact value
|
||||
- Typing a float value shows its bit pattern
|
||||
- Auto-switch to 32-bit or 64-bit width based on selected float format
|
||||
- Support float32 and float64 formats
|
||||
- Verify: 0x3F800000 = 1.0 (float32), special values display correctly,
|
||||
bit toggling updates float display, `3.14` shows nearest representation
|
||||
|
||||
### Task 5.4: Implement programmer mode TUI view - bit grid [DONE - merged into 5.3]
|
||||
- Bit grid widget: 8 bits per group, groups separated by space
|
||||
- Arrow key navigation (left/right moves cursor across bits, up/down between rows for 32/64-bit)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue