From c4eb4357167855bded6ed3567917896bc1b43412 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 18 Mar 2021 13:03:43 -0700 Subject: [PATCH] decimals: change pprint* to not use formatting.private:format-decimal. --- extra/decimals/decimals.factor | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/extra/decimals/decimals.factor b/extra/decimals/decimals.factor index cb33fb4e2c..eaa9d408e5 100644 --- a/extra/decimals/decimals.factor +++ b/extra/decimals/decimals.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators.short-circuit formatting.private -kernel lexer locals math math.functions math.order math.parser -prettyprint.backend prettyprint.custom prettyprint.sections -sequences splitting ; +USING: accessors combinators.short-circuit kernel lexer math +math.functions math.order math.parser prettyprint.backend +prettyprint.custom prettyprint.sections sequences splitting +strings ; IN: decimals TUPLE: decimal { mantissa read-only } { exponent read-only } ; @@ -86,5 +86,15 @@ M: decimal <=> M: decimal pprint* \ DECIMAL: [ - >decimal< [ 10^ * ] [ abs format-decimal ] bi text + [ mantissa>> abs number>string ] + [ + exponent>> dup 0 > [ CHAR: 0 append ] [ + dup 0 < [ + abs + [ CHAR: 0 pad-head ] [ cut-slice* ] bi + over empty? [ nip "0." prepend ] [ "." glue ] if + ] [ drop ] if + ] if + ] + [ mantissa>> 0 < [ "-" prepend ] when ] tri text ] pprint-prefix ; -- 2.34.1