✓
Passing This code compiles and runs correctly.
Code
// std/num:powf — a^e for real e via exp(e*ln a). Integral non-negative
// exponents take the exact pow path. Negative base is |neg-base (complex is
// out of scope); a==0 with e<=0 is |non-pos; huge results |overflow.
import std/io
import std/num
std/num:lit(4)
| exact a |> std/num:lit(0.5)
| exact b |> std/num:powf(a, e: b, prec: 30)
| exact r |> std/io:print.ln("{{ r:s }}") |> std/num:free(n: r)
| neg-base |> std/io:print.ln("nb")
| non-pos |> std/io:print.ln("np")
| overflow |> std/io:print.ln("of")
| bad y |> std/io:print.ln("bad-b")
| bad x |> std/io:print.ln("bad-a")
std/num:lit(2)
| exact a |> std/num:lit(0.5)
| exact b |> std/num:powf(a, e: b, prec: 30)
| exact r |> std/io:print.ln("{{ r:s }}") |> std/num:free(n: r)
| neg-base |> std/io:print.ln("nb")
| non-pos |> std/io:print.ln("np")
| overflow |> std/io:print.ln("of")
| bad y |> std/io:print.ln("bad-b")
| bad x |> std/io:print.ln("bad-a")
std/num:lit(4)
| exact a |> std/num:lit(2)
| exact b |> std/num:powf(a, e: b, prec: 30)
| exact r |> std/io:print.ln("{{ r:s }}") |> std/num:free(n: r)
| neg-base |> std/io:print.ln("nb")
| non-pos |> std/io:print.ln("np")
| overflow |> std/io:print.ln("of")
| bad y |> std/io:print.ln("bad-b")
| bad x |> std/io:print.ln("bad-a")
std/num:lit(-4)
| exact a |> std/num:lit(0.5)
| exact b |> std/num:powf(a, e: b, prec: 20)
| exact r |> std/io:print.ln("{{ r:s }}") |> std/num:free(n: r)
| neg-base |> std/io:print.ln("powf:neg-base")
| non-pos |> std/io:print.ln("np")
| overflow |> std/io:print.ln("of")
| bad y |> std/io:print.ln("bad-b")
| bad x |> std/io:print.ln("bad-a")
std/num:lit(0)
| exact a |> std/num:lit(-1)
| exact b |> std/num:powf(a, e: b, prec: 20)
| exact r |> std/io:print.ln("{{ r:s }}") |> std/num:free(n: r)
| neg-base |> std/io:print.ln("nb")
| non-pos |> std/io:print.ln("powf:non-pos")
| overflow |> std/io:print.ln("of")
| bad y |> std/io:print.ln("bad-b")
| bad x |> std/io:print.ln("bad-a")
Actual
1.99999999999999999999999999999e0
1.4142135623730950488016887242e0
1.6e1
powf:neg-base
powf:non-pos
Expected output
1.99999999999999999999999999999e0
1.4142135623730950488016887242e0
1.6e1
powf:neg-base
powf:non-pos
Flows
flow ~lit click a branch to expand · @labels scroll to their anchor
lit (expr: 4)
flow ~lit click a branch to expand · @labels scroll to their anchor
lit (expr: 2)
flow ~lit click a branch to expand · @labels scroll to their anchor
lit (expr: 4)
flow ~lit click a branch to expand · @labels scroll to their anchor
lit (expr: -4)
flow ~lit click a branch to expand · @labels scroll to their anchor
lit (expr: 0)
Test Configuration
MUST_RUN