Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
7.125 "%09.3f" s:strfmt
|
||||
. cr
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
PROGRAM FORMATTED
|
||||
|
||||
PROCEDURE FORMATTED_PRINT(N,LENGTH,DEC_PLACES->FP$)
|
||||
|
||||
LOCAL I,C$,NN$
|
||||
|
||||
FORMAT$=STRING$(LENGTH,"#")+"."
|
||||
|
||||
FOR I=1 TO DEC_PLACES DO
|
||||
FORMAT$=FORMAT$+"#"
|
||||
END FOR
|
||||
|
||||
OPEN("O",1,"FORMAT.$$$")
|
||||
WRITE(#1,FORMAT$;N)
|
||||
CLOSE(1)
|
||||
|
||||
OPEN("I",1,"FORMAT.$$$")
|
||||
INPUT(LINE,#1,N$)
|
||||
CLOSE(1)
|
||||
|
||||
! add leading zeros
|
||||
FOR I=1 TO LEN(N$) DO
|
||||
C$=MID$(N$,I,1)
|
||||
IF C$=" " OR C$="%" THEN NN$=NN$+"0" ELSE NN$=NN$+C$
|
||||
END FOR
|
||||
|
||||
FP$=RIGHT$("000000000000"+NN$,LENGTH) ! chop to required length
|
||||
|
||||
END PROCEDURE
|
||||
|
||||
BEGIN
|
||||
|
||||
PRINT(CHR$(12);) ! CLS
|
||||
|
||||
FOR I=1 TO 10 DO
|
||||
N=RND(1)*10^(INT(10*RND(1))-2)
|
||||
FORMATTED_PRINT(N,16,5->FP$)
|
||||
PRINT("Raw number =";N;TAB(30);"Using custom function =";FP$)
|
||||
END FOR
|
||||
|
||||
END PROGRAM
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
#Include "vbcompat.bi"
|
||||
|
||||
Dim s As String = Format(7.125, "00000.0##")
|
||||
Print s
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
print using "0000#.###"; 7.125
|
||||
|
|
@ -0,0 +1 @@
|
|||
7.125 -> asstring(-precision = 3, -padding = 9, -padchar = '0')
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import strfmt
|
||||
const r = 7.125
|
||||
echo r
|
||||
echo((-r).format("9.3f"))
|
||||
echo(r.format("9.3f"))
|
||||
echo((-r).format("09.3f"))
|
||||
echo(r.format("09.3f"))
|
||||
|
|
@ -0,0 +1 @@
|
|||
printf(1,"%09.3f\n",7.125)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
decimals(3)
|
||||
see fixedprint(7.125, 5) + nl
|
||||
|
||||
func fixedprint num, digs
|
||||
for i = 1 to digs - len(string(floor(num)))
|
||||
see "0"
|
||||
next
|
||||
see num + nl
|
||||
|
|
@ -0,0 +1 @@
|
|||
printf("%09.3f\n", 7.125);
|
||||
|
|
@ -0,0 +1 @@
|
|||
say ("%09.3f" % 7.125);
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
def pp0(width):
|
||||
tostring
|
||||
| if width > length then (width - length) * "0" + . else . end;
|
||||
|
||||
# pp(left; right) formats a decimal number to occupy
|
||||
# (left+right+1) positions if possible,
|
||||
# where "left" is the number of characters to the left of
|
||||
# the decimal point, and similarly for "right".
|
||||
def pp(left; right):
|
||||
def lpad: if (left > length) then ((left - length) * "0") + . else . end;
|
||||
tostring as $s
|
||||
| $s
|
||||
| index(".") as $ix
|
||||
| ((if $ix then $s[0:$ix] else $s end) | lpad) + "." +
|
||||
(if $ix then $s[$ix+1:] | .[0:right] else "" end);
|
||||
|
|
@ -0,0 +1 @@
|
|||
(1.0, 12.3, 333.333, 1e6) | pp0(10)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
0000000001
|
||||
00000012.3
|
||||
000333.333
|
||||
0001000000
|
||||
|
|
@ -0,0 +1 @@
|
|||
(1.0, 12.3, 333.333, 1e6) | pp(4;2)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
0001.
|
||||
0012.3
|
||||
0333.33
|
||||
1000000.
|
||||
Loading…
Add table
Add a link
Reference in a new issue