sourcelibs/Fixed/demos/counter.xtl
1⍝!/usr/bin/env xetal
2⍝ A 16-bit counter near the top of its range: twelve ticks from 65530
3⍝ read unsigned, read signed, and the carry out of the top bit (the
4⍝ tick where the count wraps). Run with "just demo-lib Fixed counter".
5ᶠˣ⁼u̲se< "Fixed"
6ticks ← 65530 + o̲ffsets 12
716 ᶠˣu̲wrap ticks ⍝ the register, read unsigned: wraps to 0
816 ᶠˣw̲rap ticks ⍝ the same bits, read signed
916 ᶠˣo̲verflow? ticks ⍝ where a 16-bit signed value is lost
1016 ᶠˣh̲ex ticks