From f78f794d42db6e8cd444225906141e3edeb44631 Mon Sep 17 00:00:00 2001 From: Max G Date: Mon, 3 Aug 2015 20:33:57 +0300 Subject: [PATCH] ++toi --- arvo/hoon.hoon | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index ed6e2b6af4..1247ad6c63 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -1,4 +1,4 @@ -:::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: +!::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: :::::: Preface :::::: :::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: ?> ?=(@ .) :: atom subject @@ -1523,6 +1523,18 @@ =. o (^add (^mul o 10) ?:(q +(u) u)) [k o] :: + ++ toi + |= [a=[e=@s a=@u]] ^- fn + ?. =((cmp:si e.a --0) -1) [%f & a] + =+ x=(abs:si e.a) + =+ y=(rsh 0 x a.a) + ?: |(=(r %d) =(r %z)) [%f & --0 y] + =+ z=(end 0 x a.a) + ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))] + =+ i=(bex (dec x)) + ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y] + ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)] + :: ++ ned |= [a=fn] ^- [%f s=? e=@s a=@u] ?: ?=([%f *] a) a @@ -1717,6 +1729,13 @@ ?: (syn:si e.a) (mul [%f s.a --0 a.a] [%f & e.a (pow 5 q)]) (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)]) + :: + ++ toi :: round to integer + |= [a=fn] ^- fn + ?. ?=([%f *] a) a + ?~ a.a [%f s.a zer] + ?: s.a (^toi +>.a) + (fli =.(r swr (^toi +>.a))) -- :: ++ ff :: ieee754 format