formatting, allow uppercase exponent for bin floats in base 2 and 8
parent
ccbb8116fc
commit
6061da92be
|
@ -23,7 +23,9 @@ HELP: printf
|
|||
{ { $snippet "%+Px" } "Base 16 General format" "real" }
|
||||
{ { $snippet "%+PX" } "Base 16 General format uppercase" "real" }
|
||||
{ { $snippet "%+Po" } "Base 8 General format" "real" }
|
||||
{ { $snippet "%+PO" } "Base 8 General format uppercase" "real" }
|
||||
{ { $snippet "%+Pb" } "Base 2 General format" "real" }
|
||||
{ { $snippet "%+PB" } "Base 2 General format uppercase" "real" }
|
||||
{ { $snippet "%+P.De" } "Base 10 Scientific format" "real" }
|
||||
{ { $snippet "%+P.DE" } "Base 10 Scientific format uppercase" "real" }
|
||||
{ { $snippet "%+P.Df" } "Base 10 Fixed format" "real" }
|
||||
|
|
|
@ -89,7 +89,9 @@ IN: formatting.tests
|
|||
{ "1.9p0" } [ 1.5625 "%x" sprintf ] unit-test
|
||||
{ "1.9P0" } [ 1.5625 "%X" sprintf ] unit-test
|
||||
{ "1.44p0" } [ 1.5625 "%o" sprintf ] unit-test
|
||||
{ "1.44P0" } [ 1.5625 "%O" sprintf ] unit-test
|
||||
{ "1.1001p0" } [ 1.5625 "%b" sprintf ] unit-test
|
||||
{ "1.1001P0" } [ 1.5625 "%B" sprintf ] unit-test
|
||||
{ "14+17/20" } [ 14+17/20 "%d" sprintf ] unit-test
|
||||
{ "e+11/14" } [ 14+17/20 "%x" sprintf ] unit-test
|
||||
{ "E+11/14" } [ 14+17/20 "%X" sprintf ] unit-test
|
||||
|
|
|
@ -115,7 +115,9 @@ fmt-S = "S" => [[ [ present >upper ] ]]
|
|||
fmt-u = "u" => [[ [ unparse ] ]]
|
||||
fmt-d = "d" => [[ [ number>string ] ]]
|
||||
fmt-o = "o" => [[ [ >oct ] ]]
|
||||
fmt-O = "O" => [[ [ >oct >upper ] ]]
|
||||
fmt-b = "b" => [[ [ >bin ] ]]
|
||||
fmt-B = "B" => [[ [ >bin >upper ] ]]
|
||||
fmt-e = digits "e" => [[ first '[ _ format-scientific ] ]]
|
||||
fmt-E = digits "E" => [[ first '[ _ format-scientific >upper ] ]]
|
||||
fmt-f = digits "f" => [[ first '[ _ format-decimal ] ]]
|
||||
|
@ -126,7 +128,7 @@ unknown = (.)* => [[ unknown-printf-directive ]]
|
|||
strings_ = fmt-c|fmt-C|fmt-s|fmt-S|fmt-u
|
||||
strings = pad width strings_ => [[ <reversed> compose-all ]]
|
||||
|
||||
numbers_ = fmt-d|fmt-o|fmt-b|fmt-e|fmt-E|fmt-f|fmt-x|fmt-X
|
||||
numbers_ = fmt-d|fmt-o|fmt-O|fmt-b|fmt-B|fmt-e|fmt-E|fmt-f|fmt-x|fmt-X
|
||||
numbers = sign pad numbers_ => [[ unclip-last prefix compose-all [ fix-sign ] append ]]
|
||||
|
||||
types = strings|numbers
|
||||
|
|
Loading…
Reference in New Issue