From: John Benediktsson Date: Thu, 18 Mar 2021 20:03:43 +0000 (-0700) Subject: decimals: change pprint* to not use formatting.private:format-decimal. X-Git-Tag: 0.99~2435 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=c4eb4357167855bded6ed3567917896bc1b43412 decimals: change pprint* to not use formatting.private:format-decimal. --- 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 ;