Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,4 +1,4 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. SAMPLE.
|
||||
|
||||
DATA DIVISION.
|
||||
|
|
|
|||
15
Task/Binary-digits/Component-Pascal/binary-digits.component
Normal file
15
Task/Binary-digits/Component-Pascal/binary-digits.component
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
MODULE BinaryDigits;
|
||||
IMPORT StdLog,Strings;
|
||||
|
||||
PROCEDURE Do*;
|
||||
VAR
|
||||
str : ARRAY 33 OF CHAR;
|
||||
BEGIN
|
||||
Strings.IntToStringForm(5,2,32,'0',FALSE,str);
|
||||
StdLog.Int(5);StdLog.String(":> " + str);StdLog.Ln;
|
||||
Strings.IntToStringForm(50,2,32,'0',FALSE,str);
|
||||
StdLog.Int(50);StdLog.String(":> " + str);StdLog.Ln;
|
||||
Strings.IntToStringForm(9000,2,32,'0',FALSE,str);
|
||||
StdLog.Int(9000);StdLog.String(":> " + str);StdLog.Ln;
|
||||
END Do;
|
||||
END BinaryDigits.
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#define std'dictionary'*.
|
||||
#define ext'convertors'*.
|
||||
#define system.
|
||||
#define extensions.
|
||||
|
||||
// --- Program ---
|
||||
|
||||
#symbol Program =
|
||||
#symbol program =
|
||||
[
|
||||
'program'output write &numeric:5 &radix:2 &:eintformatter << "%n".
|
||||
'program'output write &numeric:50 &radix:2 &:eintformatter << "%n".
|
||||
'program'output write &numeric:9000 &radix:2 &:eintformatter << "%n".
|
||||
console writeLine:(convertControl toLiteral:5 &radix:2).
|
||||
console writeLine:(convertControl toLiteral:50 &radix:2).
|
||||
console writeLine:(convertControl toLiteral:9000 &radix:2).
|
||||
].
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
> printf( "%d\n", convert( 50, 'binary' ) );
|
||||
> convert( 50, 'binary' );
|
||||
110010
|
||||
> printf( "%d\n", convert( 9000, 'binary' ) );
|
||||
> convert( 9000, 'binary' );
|
||||
10001100101000
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
/*REXX program demonstrates converting decimal ───► binary. */
|
||||
numeric digits 1000
|
||||
x.=
|
||||
x.1 = 0
|
||||
x.2 = 5
|
||||
x.3 = 50
|
||||
x.4 = 9000
|
||||
do j=1 for 4
|
||||
y = x2b(d2x(x.j)) + 0
|
||||
do j=1 while x.j\=='' /*compute until a NULL is found.*/
|
||||
y = x2b(d2x(x.j)) + 0 /*force removal of leading zeroes*/
|
||||
say right(x.j,20) 'decimal, and in binary:' y
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
/*REXX program demonstrates converting decimal ───► binary. */
|
||||
x.=
|
||||
x.1 = 0
|
||||
x.2 = 5
|
||||
x.3 = 50
|
||||
x.4 = 9000
|
||||
do j=1 for 4
|
||||
do j=1 while x.j\=='' /*compute until a NULL is found.*/
|
||||
y = strip( x2b( d2x( x.j )), 'L', 0)
|
||||
if y=='' then y=0
|
||||
if y=='' then y=0 /*handle special case of 0 (zero)*/
|
||||
say right(x.j,20) 'decimal, and in binary:' y
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
/*REXX program demonstrates converting decimal ───► binary. */
|
||||
x.1 = 0
|
||||
x.2 = 5
|
||||
x.3 = 50
|
||||
x.4 = 9000
|
||||
do j=1 for 4
|
||||
x.=
|
||||
x.1=0
|
||||
x.2=5
|
||||
x.3=50
|
||||
x.4=9000
|
||||
do j=1 while x.j\=='' /*compute until a NULL is found.*/
|
||||
y = word( strip( x2b( d2x( x.j )), 'L', 0) 0, 1)
|
||||
say right(x.j,20) 'decimal, and in binary:' y
|
||||
end /*j*/
|
||||
|
|
|
|||
16
Task/Binary-digits/REXX/binary-digits-4.rexx
Normal file
16
Task/Binary-digits/REXX/binary-digits-4.rexx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*REXX program demonstrates converting decimal ───► binary. */
|
||||
numeric digits 200
|
||||
x.=
|
||||
x.1=0
|
||||
x.2=5
|
||||
x.3=50
|
||||
x.4=9000
|
||||
x.5=423785674235000123456789
|
||||
x.6=1e138 /*one quinquaquadragintillion. */
|
||||
|
||||
do j=1 while x.j\=='' /*compute until a NULL is found.*/
|
||||
y = strip( x2b( d2x( x.j )), 'L', 0)
|
||||
if y=='' then y=0 /*handle special case of 0 (zero)*/
|
||||
say y
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
5 toBinaryString // 101
|
||||
50 toBinaryString // 110010
|
||||
9000 toBinaryString // 10001100101000
|
||||
import scala.language.postfixOps
|
||||
object BinaryDigits {
|
||||
(5 toBinaryString).reverse.padTo(14, '0').reverse
|
||||
//> res0: String = 00000000000101
|
||||
(50 toBinaryString).reverse.padTo(14, '0').reverse
|
||||
//> res1: String = 00000000110010
|
||||
(9000 toBinaryString).reverse.padTo(14, '0').reverse
|
||||
//> res2: String = 10001100101000
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue