Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
53
Task/Binary-digits/M2000-Interpreter/binary-digits.m2000
Normal file
53
Task/Binary-digits/M2000-Interpreter/binary-digits.m2000
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
Module Checkit {
|
||||
Form 90, 40
|
||||
Function BinFunc${
|
||||
Dim Base 0, One$(16)
|
||||
One$( 0 ) = "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"
|
||||
=lambda$ One$() (x, oct as long=4, bypass as boolean=True) ->{
|
||||
if oct>0 and oct<5 then {
|
||||
oct=2*(int(4-oct) mod 4+1)-1
|
||||
} Else oct=1
|
||||
hx$ = Hex$(x, 4 )
|
||||
Def Ret$
|
||||
If Bypass then {
|
||||
For i= oct to len(hx$)
|
||||
if bypass Then if Mid$(hx$, i, 1 )="0" Else bypass=false
|
||||
If bypass and i<>Len(hx$) Then Continue
|
||||
Ret$ += One$( EVal( "0x" + Mid$(hx$, i, 1 ) ) )
|
||||
Next i
|
||||
oct=instr(Ret$, "1")
|
||||
if oct=0 then {
|
||||
Ret$="0"
|
||||
} Else Ret$=mid$(Ret$, oct)
|
||||
} Else {
|
||||
For i= oct to len(hx$)
|
||||
Ret$ += One$( EVal( "0x" + Mid$(hx$, i, 1 ) ) )
|
||||
Next i
|
||||
}
|
||||
=Ret$
|
||||
}
|
||||
}
|
||||
Bin$=BinFunc$()
|
||||
Stack New {
|
||||
Data 9, 50, 9000
|
||||
While not empty {
|
||||
Read x
|
||||
Print Format$("The decimal value {0::-10} should produce an output of {1:-32}",x, Bin$(x) )
|
||||
}
|
||||
}
|
||||
Stack New {
|
||||
Data 9, 50, 9000
|
||||
While not empty {
|
||||
Read x
|
||||
Print Format$("The decimal value {0::-10} should produce an output of {1:-32}",x, Bin$(x,,false) )
|
||||
}
|
||||
}
|
||||
Stack New {
|
||||
Data 9, 50, 9000
|
||||
While not empty {
|
||||
Read x
|
||||
Print Bin$(x)
|
||||
}
|
||||
}
|
||||
}
|
||||
Checkit
|
||||
Loading…
Add table
Add a link
Reference in a new issue