Transaction
F68FED79396423…4E773120332E
Block 26,068 · index 0 · indexed
Summary
- Hash
- F68FED79396423AD5C7968A7F78FEDE736049F19F9FE8868DE384E773120332E
- Block
- 26,068
- Size
- 4267 bytes
- Gas used
- 8,688,408 / 10,426,149
- Fee
- 1000000ugnot
- Memo
- gnopublish
- Status
- success
Messages
Arguments · 9
- #1fractiondemo
- #2README.md
- #3# Fractions > ⚠️ **Experimental — generated with no human supervision** by the daily MCP pipeline to exercise gno tooling. Not audited. See [r/moul/x/daily](https://github.com/moul/gno-contracts/blob/main/r/moul/x/daily/README.md). --- Shows thirds summing to exactly one, the four operations, and a comparison that a decimal detour would get wrong. Demo of the [`p/moul/x/daily/fraction`](https://github.com/moul/gno-contracts/tree/main/p/moul/x/daily/fraction/v0) library — no arithmetic lives here. Stateless, so `Render` is deterministic. The comparison is the interesting row: `1/3` and `33333/100000` agree to five decimal places, and the library still reports which is larger, because `Cmp` cross-multiplies instead of converting to decimal. Built for gno 0.9. <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:**  > 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
- #4fractiondemo.gno
- #5// Package fractiondemo is a small gnoweb demo of the exact rational arithmetic // provided by the [p/moul/x/daily/fraction](/p/moul/x/daily/fraction/v0) // library: it shows thirds summing to exactly one, and a comparison that a // decimal detour would get wrong. // // It contains no arithmetic of its own. Stateless, so Render is deterministic. package fractiondemo import ( "strings" "gno.land/p/moul/x/daily/fraction/v0" ) // Render renders the demo for gnoweb. func Render(path string) string { var b strings.Builder b.WriteString("# Fractions\n\n") b.WriteString("Exact rational arithmetic, demoing the ") b.WriteString("[`p/moul/x/daily/fraction`](/p/moul/x/daily/fraction/v0) library.\n\n") third, _ := fraction.New(1, 3) sum, _ := third.Add(third) sum, _ = sum.Add(third) b.WriteString("## A third, three times\n\n") b.WriteString("`1/3 + 1/3 + 1/3` = **") b.WriteString(sum.String()) b.WriteString("**, exactly — not 0.9999…\n\n") b.WriteString("As a decimal it is only ever an approximation: `") b.WriteString(fraction.Decimal(third, 10)) b.WriteString("`\n") half, _ := fraction.New(1, 2) b.WriteString("\n## Arithmetic\n\n| expression | result |\n|---|---|\n") add, _ := half.Add(third) sub, _ := half.Sub(third) mul, _ := half.Mul(third) div, _ := half.Div(third) row(&b, "1/2 + 1/3", add.String()) row(&b, "1/2 - 1/3", sub.String()) row(&b, "1/2 × 1/3", mul.String()) row(&b, "1/2 ÷ 1/3", div.String()) approx, _ := fraction.New(33333, 100000) b.WriteString("\n## Exact comparison\n\n") b.WriteString("`1/3` vs `33333/100000` — identical to five decimal places, ") b.WriteString("yet the library still knows which is larger: **") if third.Cmp(approx) > 0 { b.WriteString("1/3 is greater") } else { b.WriteString("33333/100000 is greater or equal") } b.WriteString("**\n\n") b.WriteString("> Comparison cross-multiplies, so it never takes a decimal detour. ") b.WriteString("There are no floats here: on a chain, an answer that depends on ") b.WriteString("rounding is a consensus bug.\n") return b.String() } func row(b *strings.Builder, expr, res string) { b.WriteString("| `") b.WriteString(expr) b.WriteString("` | `") b.WriteString(res) b.WriteString("` |\n") }
- #6gnomod.toml
- #7module = "gno.land/r/moul/x/daily/fractiondemo/v0" gno = "0.9"
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]