Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

render_example_test.gno

0.93 Kb · 31 lines
 1package fractiondemo
 2
 3// ExampleRender pins the realm's Render output as a testable example.
 4func ExampleRender() {
 5	print(Render(""))
 6	// Output:
 7	// # Fractions
 8	//
 9	// Exact rational arithmetic, demoing the [`p/moul/x/daily/fraction`](/p/moul/x/daily/fraction/v0) library.
10	//
11	// ## A third, three times
12	//
13	// `1/3 + 1/3 + 1/3` = **1**, exactly — not 0.9999…
14	//
15	// As a decimal it is only ever an approximation: `0.3333333333`
16	//
17	// ## Arithmetic
18	//
19	// | expression | result |
20	// |---|---|
21	// | `1/2 + 1/3` | `5/6` |
22	// | `1/2 - 1/3` | `1/6` |
23	// | `1/2 × 1/3` | `1/6` |
24	// | `1/2 ÷ 1/3` | `3/2` |
25	//
26	// ## Exact comparison
27	//
28	// `1/3` vs `33333/100000` — identical to five decimal places, yet the library still knows which is larger: **1/3 is greater**
29	//
30	// > Comparison cross-multiplies, so it never takes a decimal detour. There are no floats here: on a chain, an answer that depends on rounding is a consensus bug.
31}