langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,16 @@
/* NetRexx */
options replace format comments java crossref savelog symbols binary
import java.text.MessageFormat
sevenPointOneTwoFive = double 7.125
-- using NetRexx Built-In Functions (BIFs)
say Rexx(sevenPointOneTwoFive).format(5, 3).changestr(' ', '0')
-- using Java library constructs
System.out.printf('%09.3f\n', [Double(sevenPointOneTwoFive)])
say MessageFormat.format('{0,number,#00000.###}', [Double(sevenPointOneTwoFive)])
return

View file

@ -0,0 +1 @@
Printf.printf "%09.3f\n" 7.125

View file

@ -0,0 +1 @@
Out.Real(7.125, 9, 0);

View file

@ -0,0 +1 @@
NSLog(@"%09.3f", 7.125);

View file

@ -0,0 +1 @@
NSLog(@"%@", [NSString stringWithFormat:@"%09.3f", 7.125]);

View file

@ -0,0 +1,3 @@
MESSAGE
STRING( 7.125, "99999.999" )
VIEW-AS ALERT-BOX.

View file

@ -0,0 +1,11 @@
declare
fun {PrintFloat X Prec}
{Property.put 'print.floatPrecision' Prec}
S = {Float.toString X}
in
{Append
for I in 1..Prec-{Length S}+1 collect:C do {C &0} end
S}
end
in
{System.showInfo {PrintFloat 7.125 8}}

View file

@ -0,0 +1 @@
printf("%09.4f\n", Pi)

View file

@ -0,0 +1,3 @@
put edit (X) (p'999999.V999'); /* Western format. */
put edit (X) (p'999999,V999'); /* In European format. */

View file

@ -0,0 +1 @@
say 7.125.fmt('%09.3f');

View file

@ -0,0 +1,19 @@
;;; field of length 12, 3 digits after decimal place
format_print('~12,3,0,`*,`0F', [1299.19]);
;;; prints "00001299.190"
format_print('~12,3,0,`*,`0F', [100000000000000000]);
;;; Since the number does not fit into the field prints "************"
;;; that is stars instead of the number
format_print('~12,3,0,`*,`0F', [-1299.19]);
;;; prints "000-1299.190"
;;; that is _leading zeros_ before sign
format_print('~3,1,12,`0:$', [1299.19]);
;;; prints "00001299.190"
format_print('~3,1,12,`0:$', [-1299.19]);
;;; prints "-0001299.190"
;;; that is sign before leading zeros
format_print('~3,1,12,`0:$', [100000000000000000]);
;;; prints "100000000000000000.000"
;;; that is uses more space if the number does not fit into
;;; fixed width

View file

@ -0,0 +1 @@
'{0:00000.000}' -f 7.125

View file

@ -0,0 +1 @@
7.125.ToString('00000.000')

View file

@ -0,0 +1 @@
RSet(StrF(7.125,3),8,"0") ; Will be 0007.125

View file

@ -0,0 +1,38 @@
REBOL [
Title: "Formatted Numeric Output"
Author: oofoe
Date: 2009-12-22
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

View file

@ -0,0 +1,3 @@
7.125 "%09.3f" print
00007.125

View file

@ -0,0 +1 @@
print right$("00000";using("#####.##",7.125),8) ' => 00007.13

View file

@ -0,0 +1,7 @@
declare @n int
select @n=123
select substring(convert(char(5), 10000+@n),2,4) as FourDigits
set @n=5
print "TwoDigits: " + substring(convert(char(3), 100+@n),2,2)
--Output: 05

View file

@ -0,0 +1,14 @@
$ include "seed7_05.s7i";
include "float.s7i";
const proc: main is func
local
const float: r is 7.125;
begin
writeln( r digits 3 lpad 9);
writeln(-r digits 3 lpad 9);
writeln( r digits 3 lpad0 9);
writeln(-r digits 3 lpad0 9);
writeln( r digits 3);
writeln(-r digits 3);
end func;

View file

@ -0,0 +1 @@
print (StringCvt.padLeft #"0" 9 (Real.fmt (StringCvt.FIX (SOME 3)) 7.125) ^ "\n")

View file

@ -0,0 +1 @@
print (Format.format "%09.3f\n" [Format.REAL 7.125])

View file

@ -0,0 +1 @@
Print(7.125.Pad(9))

View file

@ -0,0 +1 @@
right("00000" & format(7.12511, "f3"), 9)

View file

@ -0,0 +1,6 @@
needs values
value n
123 to n
2 import printf
" %08d" n printf

View file

@ -0,0 +1,7 @@
#import flo
x = 7.125
#show+
t = <printf/'%09.3f' x>

View file

@ -0,0 +1,2 @@
#1 = 7125
Num_Ins(#1, FILL+COUNT, 9) Char(-3) Ins_Char('.')