// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-trit-word.t27 -- lesson 15 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-trit-word/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles this ; file, checks its constants, evaluates the tests below and writes the page; the page hands every constant to ; tool.js as window.T27_WIDGET. tool.js draws through ../ternary-kit.js and computes nothing: every number comes ; from public/widgets/tc-trit-word/logic.js, the fn bodies of the gHashTag/t27 spec in logic.t27, compiled to wasm. ; ASCII only (L3), English only (LANG-EN). ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_tc_trit_word; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-trit-word"; pub const TITLE : str = "A word of 27 trits and the 43 bits it needs"; pub const DESCRIPTION : str = "Slide the word length. k trits need the fewest bits b with 2^b >= 3^k; at 27 trits that is 43 bits, and the share in use approaches 100 percent."; pub const IMAGE_ALT : str = "Trit word card: 27 trits reach plus or minus 3,812,798,742,493 and need 43 bits. Each dot is one word length from 1 to 27 trits, the share of its bits in use climbing in a saw-tooth towards one."; pub const HOOK : str = "A 27-trit word holds what 43 bits hold, plus or minus 3.8 trillion."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [1]str = ["gHashTag/t27 specs/ternary/trits.t27 (t27#8979): every value on the page is its fn bodies, compiled to wasm (logic.js), with 18 tests and 4108 runtime asserts"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; pub const K_CARD_WIDTH : u16 = 1200; pub const K_CARD_HEIGHT : u16 = 630; pub const SAY_LOADING : str = "Loading"; pub const K_WORD_TRITS : u32 = 27; pub const K_START : u32 = 27; pub const SAY_K : str = "Trits in a word"; pub const SAY_WORD : str = "{0} trits reach +/-{1} and need {2} bits"; pub const SAY_USE : str = "{0}% of those bits carry information"; pub const SAY_PLOT : str = "share of the bits in use, 1 to 27 trits"; pub const SAY_SOURCE : str = "Logic: t27 spec ternary/trits.t27, compiled"; test the_card_is_the_share_size { assert K_CARD_WIDTH == 1200; assert K_CARD_HEIGHT == 630; assert K_CARD_WIDTH * 21 == K_CARD_HEIGHT * 40; } test the_widget_starts_where_its_card_says { assert K_WORD_TRITS == 27; }