// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/golden-gf512.t27 -- the infographic of lesson 22 of the GoldenFloat course (specs/course/goldenfloat.t27) ; Source of truth for public/widgets/golden-gf512/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles ; this file, checks its constants, evaluates the tests below and writes the page. tool.js is one import of ; ../infographic.js, which draws SAY_TABLE_* as a real and SAY_FLOW_* as an SVG diagram with a ; , black and white, and holds no words of its own. ASCII only (L3), English only (LANG-EN). ; The lesson spec it illustrates: public/t27/files/specs/numeric/gf512.t27. ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_golden_gf512; pub const KIND : str = "widget-tool"; pub const ID : str = "golden-gf512"; pub const TITLE : str = "GoldenFloat 22: GF512"; pub const DESCRIPTION : str = "GF512: 512 bits as the spec lays them out, read from gf512.t27. Lesson 22 of the GoldenFloat course."; pub const IMAGE_ALT : str = "A black and white table, GF512: 512 bits as the spec lays them out: Sign, 1 bit, SIGN_BITS; Exponent, 195 bits, EXP_BITS; Mantissa, 316 bits, MANT_BITS; Bias, 2^(195-1) - 1, BIAS = 2^(E-1) - 1; Top exponent code, 2^195 - 1, EXP_MAX = 2^E - 1."; pub const HOOK : str = "512 bits split by phi: a ratio within 0.001 of 1 / phi."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [2]str = ["The lesson spec public/t27/files/specs/numeric/gf512.t27, read when the course was authored; every number in the table is a constant, a test value or arithmetic of that file", "Nothing on this page was measured on hardware or timed; a value written into a test is said to be written in, not computed"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; ; --- The table ----------------------------------------------------------------------------- pub const SAY_TABLE_CAPTION : str = "GF512: 512 bits as the spec lays them out"; pub const SAY_TABLE_HEAD : [3]str = ["Field", "Value", "Spec constant"]; pub const SAY_TABLE_CELLS : [15]str = ["Sign", "1 bit", "SIGN_BITS", "Exponent", "195 bits", "EXP_BITS", "Mantissa", "316 bits", "MANT_BITS", "Bias", "2^(195-1) - 1", "BIAS = 2^(E-1) - 1", "Top exponent code", "2^195 - 1", "EXP_MAX = 2^E - 1"]; pub const K_TABLE_COLS : u8 = 3; pub const K_TABLE_ROWS : u8 = 5; pub const K_TABLE_CELLS : u16 = 15; ; --- The diagram and the note ---------------------------------------------------------------- pub const SAY_FLOW_TITLE : str = "How GF512 gets its split"; pub const SAY_FLOW_STEPS : [3]str = ["N = 512 bits", "E = round((512 - 1) / phi^2) = 195", "M = 512 - 1 - 195 = 316"]; pub const K_FLOW_STEPS : u8 = 3; pub const SAY_NOTE : str = "Every number above is a constant of gf512.t27; its tests check 1 + 195 + 316 = 512."; test the_cells_fill_whole_rows { assert K_TABLE_ROWS * K_TABLE_COLS == K_TABLE_CELLS; } test the_table_has_a_body { assert K_TABLE_ROWS > 0; assert K_TABLE_COLS > 0; } test the_diagram_has_every_step { assert K_FLOW_STEPS == 3; assert K_FLOW_STEPS > 1; }