Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
calc / calc-divOpenRuns on Liberas

Divide

Returns a / b as an f64. b == 0 is an error ("division by zero"), never infinity or NaN.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init calc-div --lang rust
cd calc-div && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)11 lines›
calc-div.wit
package root:component;

world root {
  export liberas:calc/operation@0.1.0;
}
package liberas:calc@0.1.0 {
  interface operation {
    apply: func(a: f64, b: f64) -> result<f64, string>;
  }
}
Test vectors2›
calc-div.cases.json
[
  {
    "args": {
      "a": 1,
      "b": 0
    }
  },
  {
    "args": {
      "a": 7,
      "b": 2
    }
  }
]
Verification5›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 2 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.