Num.dec.place: def of yaml-for-bend@0.1.1.0 Import: import yaml-for-bend@0.1.1.0/num.bend as Num Lines 123-131 of yaml-for-bend@0.1.1.0/num.bend: https://jend.leeeet.dev/read.txt?path=yaml-for-bend@0.1.1.0/num.bend&start_line=123&end_line=131 import Base # The decimal whose digits are +ds+ (no zeros at either end) with the point # +point+ places from their left, written "12.5", "0.001" or "300.0". The # point is offset by +off+ so it can be negative. def dec.place(+ds: String, +point: Nat, +off: Nat) -> String: +n = String.length(ds) when(String, String.is_empty(ds), u => "0.0", u => when(String, Nat.is_le(point, off), u => "0." ++ zeros(Nat.sub(off, point)) ++ ds, u => when(String, Nat.is_ge(Nat.sub(point, off), n), u => ds ++ zeros(Nat.sub(Nat.sub(point, off), n)) ++ ".0", u => String.take(ds, Nat.sub(point, off)) ++ "." ++ String.drop(ds, Nat.sub(point, off))))) Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_ge https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_le https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.drop https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.is_empty https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.length https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.take https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/num.bend&name=when https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/num.bend&name=zeros