Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,14 @@
|
|||
with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
|
||||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
|
||||
procedure Zero_Fill is
|
||||
Pic_String: String := "<999999.99>";
|
||||
Pic : Picture := To_Picture(Pic_String);
|
||||
type Money is delta 0.01 digits 8;
|
||||
package Money_Output is new Decimal_Output(Money);
|
||||
use Money_Output;
|
||||
|
||||
Value : Money := 37.25;
|
||||
begin
|
||||
Put(Item => Value, Pic => Pic);
|
||||
end Zero_Fill;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
on fixedlength(x, max)
|
||||
if x < 0 then
|
||||
set pref to "-"
|
||||
set x to -x
|
||||
else
|
||||
set pref to ""
|
||||
end if
|
||||
set s to x as text
|
||||
set min to (length of s) + (length of pref)
|
||||
repeat max - min times
|
||||
set s to "0" & s
|
||||
end repeat
|
||||
return pref & s
|
||||
end fixedlength
|
||||
|
||||
repeat with x in {7.125, -7.125, 77.125, 777.125}
|
||||
log fixedlength(x, 9)
|
||||
end repeat
|
||||
|
|
@ -0,0 +1 @@
|
|||
print form 7.125 -1 "|%09.3f| ; 00007.125
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 WS-EXAMPLE.
|
||||
05 X PIC 9(5)V9(3).
|
||||
PROCEDURE DIVISION.
|
||||
MOVE 7.125 TO X.
|
||||
DISPLAY X UPON CONSOLE.
|
||||
STOP RUN.
|
||||
|
|
@ -0,0 +1 @@
|
|||
(format "%09.3f" 7.125) ;=> "00007.125"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
constant r = 7.125
|
||||
printf(1,"%9.3f\n",-r)
|
||||
printf(1,"%9.3f\n",r)
|
||||
printf(1,"%-9.3f\n",r)
|
||||
printf(1,"%09.3f\n",-r)
|
||||
printf(1,"%09.3f\n",r)
|
||||
printf(1,"%-09.3f\n",r)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
to zpad :num :width :precision
|
||||
output map [ifelse ? = "| | ["0] [?]] form :num :width :precision
|
||||
end
|
||||
print zpad 7.125 9 3 ; 00007.125
|
||||
|
|
@ -1,3 +1 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #7060A8;">printf<span style="color: #0000FF;">(<span style="color: #000000;">1<span style="color: #0000FF;">,<span style="color: #008000;">"%09.3f\n"<span style="color: #0000FF;">,<span style="color: #000000;">7.125<span style="color: #0000FF;">)
|
||||
<!--
|
||||
printf(1,"%09.3f\n",7.125)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
'{0:00000.000}' -f 7.125
|
||||
|
|
@ -0,0 +1 @@
|
|||
7.125.ToString('00000.000')
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Rebol [
|
||||
Title: "Formatted Numeric Output"
|
||||
URL: http://rosettacode.org/wiki/Formatted_Numeric_Output
|
||||
]
|
||||
|
||||
; Rebol has no built-in facilities for printing pictured output.
|
||||
; However, it's not too hard to cook something up using the
|
||||
; string manipulation facilities.
|
||||
|
||||
zeropad: func [
|
||||
"Pad number with zeros or spaces. Works on entire number."
|
||||
pad "Number of characters to pad to."
|
||||
n "Number to pad."
|
||||
/space "Pad with spaces instead."
|
||||
/local nn c s
|
||||
][
|
||||
n: to-string n c: " " s: ""
|
||||
|
||||
if not space [
|
||||
c: "0"
|
||||
if #"-" = n/1 [pad: pad - 1 n: copy skip n 1 s: "-"]
|
||||
]
|
||||
|
||||
insert/dup n c (pad - length? n)
|
||||
insert n s
|
||||
n
|
||||
]
|
||||
|
||||
; These tests replicate the C example output.
|
||||
|
||||
print [zeropad/space 9 negate 7.125]
|
||||
print [zeropad/space 9 7.125]
|
||||
print 7.125
|
||||
print [zeropad 9 negate 7.125]
|
||||
print [zeropad 9 7.125]
|
||||
print 7.125
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
a = 1234.5678
|
||||
|
||||
' Round to three decimal places. Groups by default. Output = "1,234.568".
|
||||
WScript.Echo FormatNumber(a, 3)
|
||||
|
||||
' Truncate to three decimal places. Output = "1234.567".
|
||||
WScript.Echo Left(a, InStr(a, ".") + 3)
|
||||
|
||||
' Round to a whole number. Grouping disabled. Output = "1235".
|
||||
WScript.Echo FormatNumber(a, 0, , , False)
|
||||
|
||||
' Use integer portion only and pad with zeroes to fill 8 chars. Output = "00001234".
|
||||
WScript.Echo Right("00000000" & Int(a), 8)
|
||||
Loading…
Add table
Add a link
Reference in a new issue